Search code examples
javascripthtmlapimapsoverlays

Maps API zoom into an overlay


Here is what I have done so far(had to wrap in a anchor tag for some reason...)

<a src="http://jsfiddle.net/christian4423/6oe9gLLn/"></a>

With each area being a region I want to zoom into when clicked. How would I do so? As far as my research shows there is no more click event with V3. If I am wrong please let me know, and how could I make it zoom to the overlay within its bounds?


Solution

  • A shape should respond to a click event and it responds

    // In your case
    google.maps.event.addListener(polyline, 'click', function() {
        // Zoom as you wish here
        map.setZoom(map.getZoom() + 2); 
    });
    

    Perharps you should also set the center of map to the center of polygone.

    Br