Bug: Map Centering and Window Resizing

Home Forums Calendar Products Events Calendar PRO Bug: Map Centering and Window Resizing

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1151409
    Kalle
    Participant

    Hello,

    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!

    #1151410
    Kalle
    Participant

    Ok 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

    #1151837
    Andras
    Keymaster

    Hi 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,
    Andras

    #1160445
    Support Droid
    Keymaster

    Hey 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

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Bug: Map Centering and Window Resizing’ is closed to new replies.