Hallo Leute,
hab mal wieder ein Problem -.-
folgendes:
Ich habe jetz eine Karte mit Popup und allem drum und dran, nun muss ich aber noch das Image des Markers ändern.
Kann mir jemand sagen was ich in meinem Code ändern muss?
Habe es schon mit einem Icon Parameter bei der addmarker funktion probiert hat aber leider nicht geklappt.
Hir mal mein Quellcode (ohne icon definition)
<script type="text/javascript">
var map;
var layer, markers;
var currentPopup;
// different popup types
//framed
//disable the autosize for the purpose of our matrix
OpenLayers.Popup.FramedCloud.prototype.autoSize = false;
AutoSizeFramedCloud = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {
'autoSize': true
});
/*AutoSizeFramedCloudMinSize = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {
'autoSize': true,
'minSize': new OpenLayers.Size(50,50)
});*/
/*AutoSizeFramedCloudMaxSize = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {
'autoSize': true,
'maxSize': new OpenLayers.Size(100,100)
});*/
function init(){
map = new OpenLayers.Map("map");
map.addLayer(new OpenLayers.Layer.OSM());
map.setCenter(
new OpenLayers.LonLat(12.70321,50.78218).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
), 16
);
markers = new OpenLayers.Layer.Markers("Markers");
map.addLayer(markers);
map.addControl(new OpenLayers.Control.LayerSwitcher());
addMarkers();
}
function addMarkers() {
var ll, popupClass, popupContentHTML;
//anchored bubble popup small contents autosize closebox
//Marker setzen
ll = new OpenLayers.LonLat(12.70321,50.78218).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")),
popupClass = AutoSizeFramedCloud;
popupContentHTML = "<?php echo "Hallo"?>";
addMarker(ll,popupClass, popupContentHTML,true, true);
ll = new OpenLayers.LonLat(4,20).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")),
popupClass = AutoSizeFramedCloud;
popupContentHTML = "<?php echo "Hallo"?>";
addMarker(ll, popupClass, popupContentHTML,true, true);
}
/**
* Function: addMarker
* Add a new marker to the markers layer given the following lonlat,
* popupClass, and popup contents HTML. Also allow specifying
* whether or not to give the popup a close box.
*
* Parameters:
* ll - {<OpenLayers.LonLat>} Where to place the marker
* popupClass - {<OpenLayers.Class>} Which class of popup to bring up
* when the marker is clicked.
* popupContentHTML - {String} What to put in the popup
* closeBox - {Boolean} Should popup have a close box?
* overflow - {Boolean} Let the popup overflow scrollbars?
*/
function addMarker(ll, popupClass, popupContentHTML, closeBox, overflow) {
var feature = new OpenLayers.Feature(markers, ll);
feature.closeBox = closeBox;
feature.popupClass = popupClass;
feature.data.popupContentHTML = popupContentHTML;
feature.data.overflow = (overflow) ? "auto" : "hidden";
var marker = feature.createMarker();
var markerClick = function (evt) {
if (this.popup == null) {
this.popup = this.createPopup(this.closeBox);
map.addPopup(this.popup);
this.popup.show();
} else {
this.popup.toggle();
}
currentPopup = this.popup;
OpenLayers.Event.stop(evt);
};
marker.events.register("mousedown", feature, markerClick);
markers.addMarker(marker);
}
</script>