possible to echo javascript? will paypal $20 for help

Discussion in 'Programming' started by edual200, Oct 21, 2009.

  1. #1
    Using google maps, im thinking var address= is converted to latitude longitutde in this code somewere :D , i would like to be able to echo that if possible like I do php so that I can save it into a database... someone tell me its possible as I dont understand javascript at all.

    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=mykey" type="text/javascript"></script>
    <script type="text/javascript">
    //<![CDATA[
    var geocoder;
    var map;
    var address = "1145 East Main Street, Salem, VA";
    function load()
    {
    map = new GMap2(document.getElementById("map"));
    geocoder = new GClientGeocoder();
    geocoder.getLocations(address, addToMap);
    }
    function addToMap(response)
    {
    place = response.Placemark[0];
    point = new GLatLng(place.Point.coordinates[1],
    place.Point.coordinates[0]);
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(point, 15);
    marker = new GMarker(point);
    map.addOverlay(marker);
    }
    //]]>
    </script>

    Edit.....

    i found that place.Point.coordinates[1] and place.Point.coordinates[0] are both the longitute and latitude i need but how to make it output to something like
    myphp?latitude=place.Point.coordinates[1]&longitude=place.Point.coordinates[0]
     
    Last edited: Oct 21, 2009
    edual200, Oct 21, 2009 IP
  2. VladimirS

    VladimirS Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    You can send an AJAX request to server side (php) script, that will save coordinates to DB.

    Something like this (I used jQuery library (http://docs.jquery.com/Ajax/jQuery.post) to simplify code)

    $.post("saver.php", { latitude: place.Point.coordinates[1], longitude: place.Point.coordinates[0] },
        function(data){
          alert("Data Saved");
    });
    Code (markup):
    In PHP script you can access values from
    $_POST['latitude'] and $_POST['longitude']
     
    VladimirS, Oct 23, 2009 IP