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.
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
– pmargreff
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.– robssanches