0
I wonder if you can generate two XML files in the same document.
That’s the code I’ve got so far:
downloadUrl("connect_xml.php", function (data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var rua = markers[i].getAttribute("rua");
var bairro = markers[i].getAttribute("bairro");
var CEP = markers[i].getAttribute("CEP");
var cidade = markers[i].getAttribute("cidade");
var numero = markers[i].getAttribute("numero");
var image = markers[i].getAttribute("image");
var descricao = markers[i].getAttribute("descricao");
var point = new google.maps.LatLng(
(markers[i].getAttribute("lat")),
(markers[i].getAttribute("lng")));
//var lat = new google.maps.LatLng
//(markers[i].getAttribute("lat"));
// var lng = new google.maps.LatLng
// (markers[i].getAttribute("lng"));
var html = "<b>" + rua + "</b> <br/>" + bairro + "</br>" + CEP + "</br>" + cidade + "</br>" + numero + "</br>" + "</br>" + point + "<img width='80' src=" + image + ">" + "</br> <b>" + descricao + "</b>";
var icon = customIcons[descricao] || {};
var marker = createMarker(point, rua, bairro, CEP, cidade, numero, image, descricao, map);
bindInfoWindow(marker, map, infoWindow, html);
}
});
function searchLocationsNear(center) {
clearLocations();
var searchUrl = 'get_marker.php?lat=' + center.lat() + '&lng=' + center.lng() + '&radius=' + radius;
downloadUrl(searchUrl, function(data) {
var xml = parseXml(data);
var markerNodes = xml.documentElement.getElementsByTagName("marker1");
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < markerNodes.length; i++) {
var rua = markerNodes[i].getAttribute("rua");
var bairro = markerNodes[i].getAttribute("bairro");
var distance = parseFloat(markerNodes[i].getAttribute("distance"));
var latlng = new google.maps.LatLng(
parseFloat(markerNodes[i].getAttribute("lat")),
parseFloat(markerNodes[i].getAttribute("lng")));
createOption(rua, distance, i);
createMarker(latlng, rua, bairro);
bounds.extend(latlng);
}
map.fitBounds(bounds);
locationSelect.style.visibility = "visible";
locationSelect.onchange = function() {
var markerNum = locationSelect.options[locationSelect.selectedIndex].value;
google.maps.event.trigger(markers[markerNum], 'click');
};
});
}
puts more details, has some code started?
– MagicHat
You’ll have to be more specific about what you want.
– lazyFox
Thank you for your help and patience!! So, as you can see above, I have these two codes that generate me markers on a map, but the first one manages to pass me this Marker, but the second one does not, there is some kind of conflict, I can use the same return function for the two?
– Marcos Pereira
And a problem that is happening, when I put the two to run, and calls the function of creating the marker in the second xml, it superimposes the first.
– Marcos Pereira