Announcement

Collapse
No announcement yet.

Google Mpas

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Google Mpas

    Hello, im trying to add a google map and get the latitude and longitude.
    I first try using a blank application. with the following code:

    (copy paste in a blank app...)
    ---------------------
    $latitude= -27.450809;
    $longitude= -58.986476;

    $_head = "
    <!DOCTYPE html>
    <html>
    <head>
    <title>Simple Map</title>
    <meta name='viewport' content='initial-scale=1.0, user-scalable=no'>
    <meta charset='utf-8'>
    <style>
    html, body, #map-canvas {
    margin: 0;
    padding: 0;
    height: 90%;
    }
    </style>

    <script src='https://maps.googleapis.com/maps/api/js?key=AIzaSyDYaJNMFEWfDO0I3c0rpW1Qo1vRN1Ur8eU'></script>
    <script>
    var map;
    function initialize()
    {
    var myLatlng = new google.maps.LatLng(".$latitude.",".$longitude.");
    var mapOptions = {
    zoom: 16,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);

    var marker = new google.maps.Marker({
    position: myLatlng,
    map: map,
    title: 'Dependencia',
    draggable:true
    });

    marker.addListener('drag',function(event) {

    document.getElementById("latitud").value = event.latLng.lat();
    document.getElementById("longitud").value = event.latLng.lng();
    });

    marker.addListener('dragend',function(event) {
    document.getElementById("latitud").value = event.latLng.lat();
    document.getElementById("long").value = event.latLng.lng();
    });

    }

    google.maps.event.addDomListener(window, 'load', initialize);
    </script>
    </head>
    <body>
    <div id='map-canvas'></div>

    </body>
    </html>
    ";

    $escrever = ($_head);
    echo $escrever;


    -----------------------------------------------

    the problem is:
    im using a form to complete other data and i have to call the blank app to get the latitude and longitude... how can i do it?
    how can i get the values an put it on my lat and long fields of the form??


    thanks



  • #2
    Write on initial value of your fields Lang and lat of your form, values [glolong] and [glolang] for example. When you redirect to the form, pass in URL this values, somehnt like..
    ..yourproject/yurform/?glolong=somevalue&glolat=somevalue
    /Giuseppe

    Professional Scriptcase Services
    Some Customers opinions

    Comment


    • #3
      Sorry for misspelled words. I'm on mobile and cant edit, but you got the point
      /Giuseppe

      Professional Scriptcase Services
      Some Customers opinions

      Comment


      • #4
        Thank you Giu, Ive got it. !

        Comment

        Working...
        X