ollietb / OhGoogleMapFormTypeBundle

Set latitude and longitude values on a form using Google Maps
MIT License
30 stars 76 forks source link

Bug if we use it in a sonata admin tab #22

Open SebBareyre opened 9 years ago

SebBareyre commented 9 years ago

ohgoogle

Hello, I have a bug when i use this bundle in a sonata admin tab. Could you help me to solve this problem.

Thanks Seb

ollietb commented 9 years ago

@SebBareyre Check that the maps container has a set height and size when it's loaded into the page. This usually happens when the container doesn't have a fixed size or is hidden when the js is loaded.

SebBareyre commented 9 years ago

I have set width and height and it doesn't work either. I think the problem come from the map is located in a hidden tab at page loading... no ?

ollietb commented 9 years ago

@SebBareyre yes, this will happen if you try to load the map before it is visible

SebBareyre commented 9 years ago

ok and how we could solve that ?

SebBareyre commented 8 years ago

up

jan-j commented 8 years ago

@SebBareyre After showing tab with map you need to trigger following code:

var center = map.getCenter(); 
google.maps.event.trigger(map, 'resize'); 
map.setCenter(center);

This will refresh map and everything should be fine then. Middle line is significant here, other two are only to ensure center of the map will stay the same.

xmon commented 8 years ago

Any idea to trigger this code on click tab in sonataadmin?