How do I change content of div after location of the map is changed?
I have a Google map on the left, and a corresponding contents on the right.
When a user moves around the map or zoom in or zoom out, how can I dynamically change the contnets on the right given the "new" map now?
I guess I need to know the "current" map info开发者_JS百科rmation and then use that to retrieve the content corresponding to this information.
Since I don't specifically know what you want to do, hopefully these JS snippets can get you started.
You'll need to attach an event handler to your map probably in body.onload. The GMap2 "move" event fires any time the map view is changing, which may be a lot if the user is dragging or constantly zooming.
function onBodyLoad() {
//assumes you have a GMap2 object named 'map' already declared somewhere
GEvent.addListener(map, "move", onMapMove);
}
function onMapMove() {
//update right div content
}
精彩评论