ugrás a tartalomhoz

Google maps koordináták db-be mentése

rob66 · 2013. Jan. 30. (Sze), 11.55
Hali,

A felhasználó által bejelölt Google Maps koordinátákat szeretném sql db-be menteni. Erre találtam is egy jó progit a neten, ami tökéletesen működik. Annyi kiegészítést szeretnék bele, hogy egy azonosító is mentésre kerüljön (amit a lenti kódba $a-val jelöltem), csak nem tudom, hogyan tudnám átadni azt a JS-nek.

Tudna valaki segíteni?

    <title>Google Maps</title>

    
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAPDUET0Qt7p2VcSk6JNU1sBSM5jMcmVqUpI7aqV44cW1cEECiThQYkcZUPRJn9vy_TWxWvuLoOfSFBw" type="text/javascript"></script>
  </head>
  <body onunload="GUnload()">
  
  	<?php
	$a = 100;
	?>
 
    <div id="map" style="width: 550px; height: 450px"></div>
    <a href="store.htm">Back to the tutorial page</a>
 
 
    <noscript><b>JavaScript must be enabled in order for you to use Google Maps.</b> 
      However, it seems JavaScript is either disabled or not supported by your browser. 
      To view Google Maps, enable JavaScript by changing your browser options, and then 
      try again.
    </noscript>
 
 
    <script type="text/javascript">
    //<![CDATA[
    
    if (GBrowserIsCompatible()) {
 
      var lastmarker;
      var iwform = 'Enter details:<br>'
                 + '<form action="#" onsubmit="process(this); return false" action="#">'
                 + '  <textarea name="data" rows="5" cols="40"><\/textarea><br>'
                 + '  <input type="submit" value="Submit" />'
                 + '<\/form>';
 
      // == creates a draggable marker with an input form ==
      function createInputMarker(point) {
        var marker = new GMarker(point,{draggable:true, icon:G_START_ICON});
        GEvent.addListener(marker, "click", function() {
          lastmarker = marker;
          marker.openInfoWindowHtml(iwform);
        });
        map.addOverlay(marker);
        marker.openInfoWindowHtml(iwform);
        lastmarker=marker;
        return marker;
      }
 
      // == creates a "normal" marker
      function createMarker(point,text) { 
        var marker = new GMarker(point);
        GEvent.addListener(marker,"click", function() {
          marker.openInfoWindow(document.createTextNode(text));
        });
        map.addOverlay(marker);
        return marker;
      }
 
      // == Display the map, with some controls and set the initial location 
      var map = new GMap2(document.getElementById("map"),{draggableCursor:"default"});
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(47.475, 19.062),6);         /* Induló koordináta + nagyítás*/
 
      // == Listen for map click and add an input marker
      GEvent.addListener(map,"click",function(overlay,point){
        if (!overlay) {
          createInputMarker(point);
        }
      });
 
      function process(form) {
        // == obtain the data
        var details = form.data.value;
        var lat = lastmarker.getPoint().lat();
        var lng = lastmarker.getPoint().lng();
        var url = "myserver.php?lat=" +lat+ "&lng=" +lng+ "&details="+details;
 
        // ===== send the data to the server
        GDownloadUrl(url, function(doc) {    });  
 
        // == remove the input marker and replace it with a completed marker
        map.closeInfoWindow();
        var marker = createMarker(lastmarker.getPoint(),details);
        GEvent.trigger(marker,"click");
 
      }
      
    }
    
    // display a warning if the browser was not compatible
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
 
    // This Javascript is based on code provided by the
    // Community Church Javascript Team
    // http://www.bisphamchurch.org.uk/   
    // http://econym.org.uk/gmap/
 
    //]]>
    </script>
  </body>
 
</html>

 
1

<script

Poetro · 2013. Jan. 30. (Sze), 12.19
    <script type="text/javascript">
    var $a = <?php print 100 ?>;
    //...
    </script>  
  </body>  
2

Köszi! Így már jó.

rob66 · 2013. Jan. 30. (Sze), 14.05
Köszi!

Így már jó.