Hi,
bei einem Projekt ziehe ich Koordinaten, Beschreibung und Typ aus einer XML Datei.
Anschliessend erzeugt meine Factory die Overlays und Events der Marker
Code:
function createMarker(latlng,html,type) {
var typeAIcon = new GIcon(baseIcon);
typeAIcon.image = "http://maps.google.com/mapfiles/ms/icons/blue-dot.png";
var typeBIcon = new GIcon(baseIcon);
typeBIcon.image = "http://maps.google.com/mapfiles/ms/icons/red-dot.png";
var typeCIcon = new GIcon(baseIcon);
typeCIcon.image = "http://maps.google.com/mapfiles/ms/icons/yellow-dot.png";
// Set up our GMarkerOptions object
if (type=='A') {
markerOptions = { icon:typeAIcon };
}
if (type=='B') {
markerOptions = { icon:typeBIcon };
}
if (type=='C') {
markerOptions = { icon:typeCIcon };
}
var marker = new GMarker(latlng, markerOptions);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
map.addOverlay(marker);
}
Wie kann ich die jetzt nach Typ A, B und C gruppiert erstellen (vielleicht als Feld) um sie dann Gruppen komplett nach Typ ein - oder auszublenden?
Für meinen von Hand nachträglich erzeugten Marker ist das kein Thema - den kann ich togglen wie ich mag...
Code:
function initialize() {
.
.
.
VISmarker = new GMarker(new GLatLng(53.98, 13.5));
map.addOverlay(VISmarker);
.
.
.
}
function toggleVisability(markertotoggle) {
if (markertotoggle.isHidden())
markertotoggle.show();
else
markertotoggle.hide();
}
HTML-Code:
<p onclick="toggleVisability(VISmarker);">Toggle Testmarker</p>
Hat da jemand eine Idee zu?
Alternative lege ich zur Not jede mögliche Typ-Kombination als seperates XML File ab und entscheide dann zur Laufzeit welche ich will.
Aber da es um viele Marker geht und ich die Seite nicht immer neu laden will, sondern AJAX-ähnlich alles dem Client überlassen will wäre das die Notlösung.
Gruß,
dennis