Note that there are some explanatory texts on larger screens.

plurals
  1. POgoogle maps get position
    primarykey
    data
    text
    <p>I'm using Google maps api, and i got a problem when i'm trying to get markers position. i got two text fields as an address input, and i show the results with markers.</p> <p>When i want to get the markers position(by getPosition() function), for using new google.maps.LatLngBounds(),the markers position is correct on the map, but the getPosition() function, gives me a wrong answer, only on the second time i search for the address the getPosition, is updated for the first address search. it's like it has a dealy and when i'm using getPosition(), the position is not updated yet.</p> <p>anyone have any idea why?</p> <p>Thanx</p> <p>this is part of my code. if i'll use JSON request for getting the address location, will it work better?</p> <p>function GetAddress(add , map , pointtype) {</p> <pre><code>var country = 'france'; var address = add + ', ' + country; geocoder = new google.maps.Geocoder(); if(pointtype == 0){ geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { origmarker.setPosition(results[0].geometry.location) ; origmarker.setTitle(add); } }); } else{ geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { desmarker.setPosition(results[0].geometry.location) ; desmarker.setTitle(add); } }); } </code></pre> <p>}</p> <p>var bounds = new google.maps.LatLngBounds() ;</p> <p>bounds.extend(origmarker.getPosition()); bounds.extend(desmarker.getPosition());</p> <p>map.fitBounds(bounds);</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload