Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Map off center/cutting off

I have a map that is being created and it seems as part of it is being cut off or off center. I've tried adding google.maps.event.triggerr(map, 'resize') and it is still cutting off. Any ideas?

<script language="JavaScript">
 var map;
      function initialize() {
        var mapOptions = {
          zoom: 15,
          center: new google.maps.LatLng(<?=$lat?>, <?=$long?>),
          mapTypeId: google.maps.MapTypeId.ROADMAP,
      };
        map = new google.maps.Map(document.getElementById('map_canvas'),
            mapOptions);
      }
      //google.maps.event.trigger(map, 'resize');
      google.maps.event.addDomListener(window, 'load', initialize);

</script>

enter image description here

like image 296
etm124 Avatar asked Apr 14 '26 03:04

etm124


1 Answers

Make sure the div displaying your map has a size before you trigger the resize event.

like image 113
geocodezip Avatar answered Apr 15 '26 15:04

geocodezip



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!