Hello
In my JavaScript code I get the following error: "Uncaught TypeError: Can not read property 'split' of undefined". As I am new to the area, I do not understand how to solve the problem very well, can someone help me identify it?
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
var marks = [];
for (var i = 0; i < location.length; i++) {
marks[i] = createMark(i); /*ERRO*/
}
function createMark() {
var imagePath = "marker" + (i + 1) + ".png";
var image = imagePath;
var markers = [];
var lat = locations[i].split(',')[0]; /*ERRO*/
var long = locations[i].split(',')[1];
var location = new google.maps.LatLng(lat, long);
var marker = new google.maps.Marker({
position: location,
map: map,
icon: image
});
marker.setTitle("Cliente");
var textOrder = "<strong> Ponto: </strong> " + (i + 1) + ". <br> <strong> Latitude: </strong>" + lat + ", <strong> Longitude: </strong>" + long;
var infowindow = new google.maps.InfoWindow({
content: textOrder
});
google.maps.event.addListener(marker, "click", function() {
infowindow.open(map, marker);
});
}