Home › Forums › Calendar Products › Events Calendar PRO › Bug: Map Centering and Window Resizing
- This topic has 4 replies, 4 voices, and was last updated 9 years, 7 months ago by
Kalle.
-
AuthorPosts
-
August 13, 2016 at 5:23 pm #1151409
Kalle
ParticipantHello,
When resizing a browser window (ie drag edge of window), the map view does not re-center itself.
Looking in tribe-events-ajax-maps.js there is some code dealing with this:
if ( tt.map_view() ) { var center; $( "#tribe-geo-map-wrapper" ).resize( function() { center = tg.map.getCenter(); google.maps.event.trigger( tg.map, "resize" ); tg.map.setCenter( center ); } ); .....However the line “center = tg.map.getCenter();” needs to occur outside the resize function. You want to define what is center before the map got resized, otherwise the function will just center on what the new center is after resizing.
Also: a suggestion online is to add a listener to the google map call, so that it waits until the call is done before trying to re-set the center. I can’t tell if this does anything, but in theory I guess it might help someone on a super-slow connection.
So the final working code I have is:
if ( tt.map_view() ) { var center; center = tg.map.getCenter(); $( "#tribe-geo-map-wrapper" ).resize( function() { google.maps.event.trigger( tg.map, "resize" ); google.maps.event.addListener(tg.map, 'idle', function() { tg.map.setCenter( center ); }); }); .....Thanks!
August 13, 2016 at 5:32 pm #1151410Kalle
ParticipantOk I presumed a fix too soon!
A side issue presents itself: Now map panning (ie dragging) is busted. When I pan the map, it slings back to a previous center mark!
The center variable needs be set once more afterward, I suppose.
I have to run, will look at it again tomorrow.
thx
August 15, 2016 at 3:37 pm #1151837Andras
KeymasterHi Kalle,
Thanks for reaching out to us with that. I will open a ticket for that so our devs can look into it, and I will link in this thread.
Meanwhile if you find out anything more, then please post it here, so we can check.
Cheers,
AndrasSeptember 6, 2016 at 9:35 am #1160445Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Bug: Map Centering and Window Resizing’ is closed to new replies.
