Classic Google Map resize

Greetings!

I’d like to trigger a resize action on my Google map as soon as the map’s width (or windows width) is modified. I have defined a lattitude and longitude but it doesn’t recenters when the window is resized. However if I resize THEN refresh the page, everything works fine!

Can you help me out?

Hi There,

Thanks for writing in!

Can you please use this javascript to recenter the map in resize.

google.maps.event.addDomListener(window, 'resize', function() {
    var center = map.getCenter()
    google.maps.event.trigger(map, "resize")
    map.setCenter(center)
})

Please let us know how this goes!

Thanks

It’s not working. I get a “Uncaught ReferenceError: map is not defined” when I resize the window.

Hi again,

Can you please follow this thread instead https://stackoverflow.com/questions/18444161/google-maps-responsive-resize

Hope this helps!

I’d rather use Cornerstone’s Google map than to program the whole thing myself.

Is there a way to access the variable created by Cornerstone from my script?

Hey @alainfilion,

Sorry for the confusion. There is no Google Map control in Cornerstone. With that said, if you need a custom map, you will need to follow what @Nabeel suggested.

Thank you for understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.