[OpenLayers-Users] icon&popup

=?GBK?B?ufnR9NKr?= gistop at 163.com
Thu Nov 10 08:05:16 EST 2011


Dear all.
I generated the code as below.
.Actually,the marker doesn't response to mousedown.
But it works well if I remove this -------marker.icon = icon
My question is How to change marker icons?
 
Thanks in advance.
 
function addMarker() {
 var layer, markers;
 var currentPopup;
 markers = new OpenLayers.Layer.Markers("Markers");
 map.addLayer(markers);
 var size = new OpenLayers.Size(20, 20);
 var offset = new OpenLayers.Pixel(-(size.w / 2), -size.h);
 var icon = new OpenLayers.Icon('http://www.openlayers.org/dev/img/marker.png', size, offset);
 
 AutoSizeFramedCloud = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {
    'autoSize' : true
   });
 popupClass = AutoSizeFramedCloud;
 popupContentHTML = '<img src="http://www.openlayers.org/dev/img/marker.png"></img>'
 var feature = new OpenLayers.Feature(markers, new OpenLayers.LonLat(503810,4307378));
 feature.closeBox = true;
 feature.popupClass = popupClass;
 feature.data.popupContentHTML = popupContentHTML;
 feature.data.overflow = (true) ? "auto" : "hidden";
 var marker = feature.createMarker();
 marker.icon = icon
 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);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111110/40f57994/attachment.html


More information about the Users mailing list