Google Maps does not load correctly

Asked

Viewed 2,243 times

1

My site is having problems displaying on a map (Google Maps) when accessed by the main url: http://www.localizaip.com/

but displays the same map correctly when accessed by this other URL: http://www.localizaip.com/en/

If I access the site by this other url http://www.localizaip.com/es/ also gives error in map.

Would anyone know what could be causing this?

The html code of the map is created dynamically within the following div <div id="map-canvas" style="min-height:248px; width:100%;"></div>, and I have found that this div is present in both the pages I have quoted.

The functions that should dynamically create the map are:

<script src="https://maps.googleapis.com/maps/api/js?key=API_KEY"></script>

<script>
var mapMarker = "http://www.localizaip.com/site/images/geo_icon.png";
var latLngHome = new google.maps.LatLng("99,9999999","99,9999999");
var infoHome = '<div id="content">'+'<div id="siteNotice">'+'</div>'+'<h4 id="firstHeading" class="firstHeading">Localização</h4>'+'<div id="bodyContent">'+'<p>Rua Tal<br/>Bairro, Cidade<br/>Estado - Brazil</p>'+'</div>'+'</div>';  

function initialize(myLatlng,infoWindowString) {

    if($('#map-canvas').length > 0){

          //var myLatlng = new google.maps.LatLng("","");
          var mapOptions = {
            zoom: 15,
            center: myLatlng
          }
          var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

          // Image Marker
          var image = mapMarker;
          var beachMarker = new google.maps.Marker({
            position: myLatlng,
            map: map,
            icon: image,
            title: 'Localização'                
          });

          var infowindow = new google.maps.InfoWindow({
              content: infoWindowString
          });


        google.maps.event.addListener(beachMarker, 'click', function() {
            infowindow.open(map,beachMarker);
        });

    }

}

var $ = jQuery.noConflict($);
$(document).ready(function(){    
     google.maps.event.addDomListener(window, 'load', initialize(latLngHome,infoHome));
});
</script>

But for some reason it’s not working..

Note: These errors started to appear after I installed a PHP translation system on the site (php-gettext), but with the implementation of this system, no javascript changes were made, and this I found strange, because I don’t understand how a PHP system could affect the functionality of the map that is created using javascript.

2 answers

0


I found out that my problem was related to PHP language implementation scripts (php-gettext).

Below the code of how I solved:

<?php

putenv('LANGUAGE=' . $locale);
putenv('LANG=' . $locale);
//putenv('LC_ALL=' . $locale); //Desabilitei esta linha 
putenv('LC_MESSAGES=' . $locale);

setlocale(LC_MESSAGES, $locale);
setlocale(LC_CTYPE, $locale);
//setlocale(LC_ALL, $locale); //Desabilitei esta linha

?>

I believe that somehow the language setting was affecting the display of Google Maps. However disabling only two lines of the above script I was able to solve the problem, without affecting the functionality of the translation system.

-1

Good night. On the page that is working found in the code, the div that displays the map:

Already on the pages that are showing the error, I did not find this part in the code. Have you checked if it is correct? If not missing the div where the map is displayed on these error pages?

  • use the comments when you have enough score for this type of question, the answer session is only for answers that can solve the problem

  • Hi @Wesley! I checked the pages and found that div <div id="map-canvas" style="min-height:248px; width:100%;"></div> responsible for displaying the map is in both. Anyway thanks for the reply.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.