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"
autocomplete code: http://pastebin.com/YTNnDS51
google map 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 < 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){
$("<li />")
.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());
}
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
Thanks for your thoughts