Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google map API v3 redraw?

I amtrying to solve a google map problem for someone, the page has a expand tab, when clicking the expand tab it shows the full map, what's happening in the backend is changing the map div margin-right to 0, the problem is there is an area on the far right is not showing the map. I tried google.maps.event.trigger(this.map, 'resize');and it's not fixing the issue.

var resultsCont = $('#resultsCont');
var mapCont = $('#mapCont');
if (resultsCont.is(':visible')){
    resultsCont.hide();
    mapCont.css('margin-right',0);
}else{
    resultsCont.show();
    mapCont.css('margin-right',320);
}
google.maps.event.trigger(this.map, 'resize');
like image 683
James Lin Avatar asked Nov 14 '22 03:11

James Lin


1 Answers

I can't see the rest of your code, but I'm guessing that this.map is a copypasta relic. The first argument in the trigger is the maps object.

So whatever is on the left of:

var thisguy = new google.maps.Map(yada, yada)

google.maps.event.trigger(thisguy, 'resize');

Assuming it's in scope.

Could be wrong, just guessing at this point. Jebus, just checked the date ... looks like I got here a little late.

like image 149
Matej Avatar answered Nov 16 '22 04:11

Matej