I'm having an issue that is as follows: I have to make a call from a JSON that contains latitude and longitude from multiple locations and then add them to a Maps map as bookmarks. I can load both the map and JSON, but the markers are not displayed for an unknown reason. Like, the code does not show any errors in the Chrome log, but the bookmarks do not want to appear. Does anyone know how to fix this? Probably the error should be syntax, but I do not know where ...
NOTE: The JSON I can not show because it is not mine, but a company. But the JSON framework is correct.
See the code below ...
JavaSctipt (jQuery)
// js/gmap_index.js
var mapOptions;
var mapa;
var geocoder;
function CallFirstMap () {
mapOptions = {
center: new google.maps.LatLng(-29.1634031, -51.1796683),
zoom: 8,
mapTypeId: google.maps.MapTypeId.HYBRID,
scaleControl: true,
scaleControlOptions: {
position: google.maps.ControlPosition.BOTTOM_RIGHT
},
streetViewControl: true,
streetViewControlOptions: {
position: google.maps.ControlPosition.RIGHT_BOTTOM
},
mapTypeControl: true,
mapTypeControlOptions: {
position: google.maps.ControlPosition.RIGHT_BOTTOM
}
};
mapa = new google.maps.Map(document.getElementById("map"), mapOptions);
geocoder = new google.maps.Geocoder();
}
// js/callPop.js
$(document).ready (function () {
$.getJSON("my.json", function (data) {
var marcador, localMarcador;
$.each(data, function (i, arq) {
localMarcador = new google.maps.LatLng(arq.lat, arq.long);
marcador = new google.maps.Marker({
map: mapa,
position: localMarcador
});
});
});
});
HTML:
<body>
<div id="map"></div>
<script src="https://maps.googleapis.com/maps/api/js?key=my_key&callback=CallFirstMap"asyncdefer></script><!--coloqueiakeycomomy_keyparaevitarousoindevido--><scriptsrc="js/gmap_index.js"></script>