G’day!
I’d like to know, how to add a custom class, to every single marker?!
Searched the web for a while - without success. I tried to use OpenLayers.Element (http://dev.openlayers.org/docs/files/OpenLayers/BaseTypes/Element-js.html#OpenLayers.Element.hasClass) but it didn’t work out.
This is the function i wrote to add makers:
function ownMarker(lon,lat,icon,markerid) {
var size = new OpenLayers.Size(38,58);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var element = new OpenLayers.Element.addClass('div', 'test');
var icon = new OpenLayers.Icon('images/marker/'+ icon +'.png', size, offset);
var marker = new OpenLayers.Marker((new OpenLayers.LonLat(lon, lat).transform(proj4326, projmerc)),icon)
marker.id = markerid;
marker.events.register("mousedown", marker, function() {
if(this.id != 'home') {
currentID = this.id;
$('.activeResult').removeClass('activeResult');
$('#results a[href$=' + this.id + ']').addClass("activeResult");
showContent($(".nav a:first-child").attr("href"));
$(".nav a:first-child").addClass("activeContent")
if(contentOpen == false){
$("#container").show();
$(".frame").animate({left: 0});
contentOpen = true;
}
tempLatitude = $('#results a[href$=' + this.id + ']').attr("lat");
tempLongitude = $('#results a[href$=' + this.id + ']').attr("lon");
targetLatitude = $('#results a[href$=' + this.id + ']').attr("lat");
targetLongitude = $('#results a[href$=' + this.id + ']').attr("lon");
ownPanTo(tempLongitude, tempLatitude);
console.log(this.id);
}
});
markers.addMarker(marker);
}
I’d like to add the class to the div-container… not the icon(img) itself…
Cheers!
Kay