0
I’m making a request ajax code:
$.ajax({
type:"POST",
url:"url.php",
data:{
ida : href,
},
beforeSend: function(){
},
success:function(data){
$("#mapa").html(data);
}
});
Request is being made successfully, no problem. What happens is when loading the result, in this case is a google maps map, gives an error: You have included the Google Maps API Multiple times on this page. This may cause Unexpected errors.
where my url.php file is :
<div id="gmap_canvas"></div>
<div id='map-label'></div>
<!-- JavaScript to show google map -->
<script type="text/javascript" src="http://maps.google.com/maps/api/js"></script>
<script type="text/javascript">
function init_map() {
var myOptions = {
zoom: 14,
center: new google.maps.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("gmap_canvas"), myOptions);
marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>)
});
infowindow = new google.maps.InfoWindow({
content: "<?php echo $formatted_address; ?>"
});
google.maps.event.addListener(marker, "click", function () {
infowindow.open(map, marker);
});
infowindow.open(map, marker);
}
google.maps.event.addDomListener(window, 'load', init_map);
</script>
I have no other part of the reference code for inclusion of the map scritp, it is loaded directly by the url.php file via ajax.
Accessing directly in the browser the url.php works perfectly, if it is via ajax does not work, gives the reported error.
I would like to know why of the error, because I am referencing the map script only once and not multiple times according to the error reported.
worked the map, but if it is on the js console the error continues and gives another error: Google Maps API Warning: Sensornotrequired https://developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required
– lelopes