Mike
Mike

Reputation: 3418

how do I create two google maps dependant on each other

I need to create two maps. On one map I want to show the selected cities as markers and on the other dependent map, I want to show the zoomed out location of this city on click of its marker. How do I go about this.

Upvotes: 0

Views: 74

Answers (1)

Kasper Vesth
Kasper Vesth

Reputation: 4113

What you usually do with only one map is have a global variable, usually called map, that knows what div to show your map in, and this variable is used when you want to manipulate the map like put new markers on it or zoom.

I can imagine, without having tried it, that the solution to your problem would be to have two global variables, map1 and map2, that holds the reference to two maps created in their own divs.

You use map1 to hold your markers, and in your eventlistener for the markers you specify that on a click the setCenter and setZoom shall be called for map2. That should solve your problem as I see it.

Upvotes: 1

Related Questions