0
Good night,
I create the markers on the map using the method:
function addMarkersLabel() {
var latlngbounds = new google.maps.LatLngBounds();
for (var i in points) {
var marker = new MarkerWithLabel({
position: points[i].latLng,
title: points[i].titulo,
icon: points[i].icone,
zIndex: points.length - Number(i),
map: GMaps,
labelContent: points[i].labelContent,
labelAnchor: points[i].labelAnchor,
labelClass: points[i].labelClass
});
addMarkerListener(marker, points[i].id);
markers.push(marker);
latlngbounds.extend(marker.position);
}
}
But I need to allow after the map is created to show/hide the markers, using as filter the title field of the markers, if the title is equal to X, display, otherwise hidden.
Within your variable "markers", you have all the objects of Marker, ie, make an iteration on this Array "markers" and check the property title of each one. If your condition is true, then do something, if not, do something else.
– Douglas Garrido
But what is the command to access the 'title' property? for (var i = 0; i < markers.length; i++) { var Marker = markers[i]; }
– Emanuelle
Debug your code, see what’s inside
markers[i]
, because I don’t know how this method creates the object. Maybe it’s evenmarkers[i].title
, but I’m not sure, so the best thing to do is to debug the code. Use theconsole.log()
and see what returns in Console browser.– Douglas Garrido