I have the following code that creates a Google Map in PHP with an address variable
Javascript:
Start function GoogleMaps (selector) {geocoder = null; Maps = []; Limits = []; If (! Selector) {selector = '. GoogleMap '; } $ .eich ($ (selector), function (index, value) {var $ this = $ (value), mapOptions = $ this.data (), addresses = $ this.data ('address') + ''; Addresses = addresses? Addresses.split (','): []; $ this.attr ('id', 'google-map-' + index); map [index] = new google.maps.map (this, mapOptions ); [Index] = new google.maps.LatLngBounds (for; var i = 0; i PHP / HTML and JavaScript fire:
$ postpostcode = array_filter (array_unique (hash :: extract ($ address, '{n} address. .postcode '))); If (empty! $ (Postposts)) {echo $ -> this-> HTML-> Tag ('div', '', array ('class' = & gt; 'google map', 'id' = & gt; 'google-map-'. $ Uuid, 'data-address' = & gt; unarmed (',', $ Separate postodes), 'data zoom' => 5,)), $ this- & gt; HTML-> Fix map ', array (' admin '= & gt;' address', 'action' = & gt; 'ficssap', $ address ['company_id'],)); } & Lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {initialiseGoogleMaps ($ ('# google-map- & lt ;? php echo $ uuid ;? & gt;'));}); & Lt; / Script & gt;
What do I need to do, when the user transfers the map to a different position, I want to capture latitude and longitude from the DOM and save it in a mySQL through a POST request the wanted .
I have looked at the DOM for Google Maps and this LAT appears more, but they do not change whenever the map is transferred.
Can anyone help?
bounds_changed
, center_changed
/ code> or < Code> dragend (depending on what you really want), get Map Center coordinates (if you want to do that), and pass in your backend, most likely an AJAX request For help
For example:
google.maps.event.addListener (map, 'center_changed', function) {var center = map.getCenter (); // 'backend' with AJAX request 'center' variable}};
Comments
Post a Comment