delahaye / dlh_googlemaps

Google Maps Extension für Contao
20 stars 26 forks source link

Feature: resize #59

Closed marcobiedermann closed 8 years ago

marcobiedermann commented 8 years ago

Update map center point on browser resize.

KaiserCh commented 8 years ago

I don't think, re-running the initialization-function is the best option. You'll just trigger lots of functions, that don't need to be triggered. The following code should work fine, when placed inside gmap*_initialize():

google.maps.event.addDomListener(window, "resize", function() { var center = gmap<?=$this->map['id'];?>.getCenter(); google.maps.event.trigger(gmap<?=$this->map['id'];?>, "resize"); gmap<?=$this->map['id'];?>.setCenter(center); });

qzminski commented 8 years ago

@KaiserCh is right, you don't need to re-initialize the whole map. Just make sure that the map stays in the center upon window resize.

+1

marcobiedermann commented 8 years ago

@KaiserCh Thank you, I will update my PR later :)