I'm now using other Google Maps API JavaScript utilities, I've changed some parts of the code, and it ran into more or less problems this time around @Sergio helped me Link the question: Uncaught TypeError: Can not read property 'split' of undefined , follow the code JS:
JS:
var map = new google.maps.Map(document.getElementById("map"), mapOptions); // linha igual ao necessário
var marks = [];
for (var i = 0; i < location.length; i++) {
marks[i] = createMark(i); /*ERRO*/
}
function createMark(i) {
var imagePath = "marker" + (i + 1) + ".png";
var image = imagePath;
var markers = [];
if (!locations[i]) return null;
//inserindo nova parte da API
geocoder.geocode( {'address': location}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
resultsMap.setCenter(results[i].geometry.location);
var marker = new google.maps.Marker({
position: results[i].geometry.location,
map: map,
icon: image
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
}); //função inserida
marker.setTitle("Cliente"); /*ERRO*/
var textOrder = "<strong> Ponto: </strong> " + (i + 1);
var infowindow = new google.maps.InfoWindow({
content: textOrder
});
google.maps.event.addListener(marker, "click", function() {
infowindow.open(map, marker);
geocodeAddress(geocoder, map); //linha inserida
});
return marker;
} }
RETURNED ERROR:
Uncaught ReferenceError: marker is not defined
at createMark (map_clients.js:67)
at mapCreate (map_clients.js:45)
Hey, everyone!