The layer adds the marker to the div. Therefore, some of the code needs to move into the layer: the marker needs to know how to generate an HTML object that will represent it.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@102 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -12,5 +12,16 @@ OpenLayers.Layer.Marker.prototype =
|
|||||||
// Implement this. It may not need to do anything usually.
|
// Implement this. It may not need to do anything usually.
|
||||||
moveTo:function(bounds,zoomChanged) {
|
moveTo:function(bounds,zoomChanged) {
|
||||||
|
|
||||||
}
|
},
|
||||||
|
addMarker:function(marker) {
|
||||||
|
this.markers.append(marker);
|
||||||
|
var resolution = this.map.getResolution();
|
||||||
|
var extent = this.map.getExtent();
|
||||||
|
var pixel = new OpenLayers.Pixel(
|
||||||
|
resolution * (this.lonlat.lon - extent.minlon),
|
||||||
|
resolution * (extent.maxlat - this.lonlat.lat)
|
||||||
|
);
|
||||||
|
var m = marker.generateMarker(pixel);
|
||||||
|
this.div.appendChild(m);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,27 +27,9 @@ OpenLayers.Marker.prototype = {
|
|||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
this.lonlat = lonlat;
|
this.lonlat = lonlat;
|
||||||
},
|
},
|
||||||
|
generateMarker: function(pixel) {
|
||||||
/**
|
var markerObject;
|
||||||
*/
|
// Create a div here, and set the location to the pixel above
|
||||||
draw: function() {
|
return markerObject;
|
||||||
var resolution = this.map.getResolution();
|
|
||||||
var extent = this.map.getExtent();
|
|
||||||
if ( (this.lonlat.lat > extent.minlat)
|
|
||||||
&& (this.lonlat.lat < extent.maxlat)
|
|
||||||
&& (this.lonlat.lon > extent.minlon)
|
|
||||||
&& (this.lonlat.lon < extent.maxlon)) {
|
|
||||||
|
|
||||||
var pixel = new OpenLayers.Pixel(
|
|
||||||
resolution * (this.lonlat.lon - extent.minlon),
|
|
||||||
resolution * (extent.maxlat - this.lonlat.lat)
|
|
||||||
);
|
|
||||||
// need to account for how much layer has moved...
|
|
||||||
/* Psuedocode:
|
|
||||||
div = map.markersDiv;
|
|
||||||
marker = OpenLayers.Util.createDiv('marker'+rand(), pixel, this.icon.size, null, this.icon.url);
|
|
||||||
div.appendChild(marker);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user