Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery autocomplete result for google map api
    text
    copied!<p>I'm using jQuery's autocomplete. I'd like to draw the map based on the result that is selected from the autocomplete. I have the lat/long to use captured in variable "latlong"</p> <p>autocomplete code: <a href="http://pastebin.com/YTNnDS51" rel="nofollow">http://pastebin.com/YTNnDS51</a></p> <p>google map code:</p> <pre><code> var map = new GMap2($("#map").get(0)); var burnsvilleMN = new GLatLng(latlong); map.setCenter(burnsvilleMN, 8); // setup 10 random points var bounds = map.getBounds(); var southWest = bounds.getSouthWest(); var northEast = bounds.getNorthEast(); var lngSpan = northEast.lng() - southWest.lng(); var latSpan = northEast.lat() - southWest.lat(); var markers = []; for (var i = 0; i &lt; 10; i++) { var point = new GLatLng(southWest.lat() + latSpan * Math.random(), southWest.lng() + lngSpan * Math.random()); marker = new GMarker(point); map.addOverlay(marker); markers[i] = marker; } $(markers).each(function(i,marker){ $("&lt;li /&gt;") .html("Point "+i) .click(function(){ displayPoint(marker, i); }) .appendTo("#list"); GEvent.addListener(marker, "click", function(){ displayPoint(marker, i); }); }); $("#message").appendTo(map.getPane(G_MAP_FLOAT_SHADOW_PANE)); function displayPoint(marker, index){ $("#message").hide(); var moveEnd = GEvent.addListener(map, "moveend", function(){ var markerOffset = map.fromLatLngToDivPixel(marker.getLatLng()); $("#message") .fadeIn() .css({ top:markerOffset.y, left:markerOffset.x }); GEvent.removeListener(moveEnd); }); map.panTo(marker.getLatLng()); } </code></pre> <p>if i put the google map code anywhere in the page with a hard coded lat/long it draws it fine. The problem is that for my use I need to wait to draw the map until after the autocomplete event happens so that I can capture the correct lat/long. I'm not sure how to trigger the google map to refresh once I've captured that lat/long</p> <p>Thanks for your thoughts</p>
 

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