here is how to make the map center upon resize
-
you should make the map center itself when resizing or when it’s responsive
after line 65 (end of the map_options function), put this:
google.maps.event.addDomListener(window, "resize", function() { var center = map_<?php echo $map_id ; ?>.getCenter(); google.maps.event.trigger(map_<?php echo $map_id ; ?>, "resize"); map_<?php echo $map_id ; ?>.setCenter(center); });
(from quick googling -> https://hsmoore.com/keep-google-map-v3-centered-when-browser-is-resized/ )
my map is 100% width in a container div that is of varying widths, seems to work fine
great plugin btw! i dont need a giant monster plugin, just need one map with one location!
https://www.ads-software.com/plugins/simple-google-maps-short-code/
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘here is how to make the map center upon resize’ is closed to new replies.