add 'offset' member to OpenLayers.Icon - and then use it in OpenLayers.Marker
git-svn-id: http://svn.openlayers.org/trunk/openlayers@127 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+12
-1
@@ -6,10 +6,21 @@ OpenLayers.Icon.prototype = {
|
|||||||
|
|
||||||
// {OpenLayers.Size}: size of image
|
// {OpenLayers.Size}: size of image
|
||||||
size:null,
|
size:null,
|
||||||
|
|
||||||
|
/** distance in pixels to offset the image when being rendered
|
||||||
|
* @type OpenLayers.Pixel */
|
||||||
|
offset: null,
|
||||||
|
|
||||||
initialize: function(url, size) {
|
initialize: function(url, size, offset) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
|
|
||||||
|
this.offset = offset;
|
||||||
|
if (offset == null) {
|
||||||
|
// default offset
|
||||||
|
this.offset = new OpenLayers.Pixel(size.w / 2, size.h);
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Create a copy of this icon.
|
// Create a copy of this icon.
|
||||||
|
|||||||
@@ -38,9 +38,7 @@ OpenLayers.Marker.prototype = {
|
|||||||
generateMarker: function(pixel) {
|
generateMarker: function(pixel) {
|
||||||
// Create a div here, and set the location to the pixel above modified
|
// Create a div here, and set the location to the pixel above modified
|
||||||
// by the icon size.
|
// by the icon size.
|
||||||
var markerOffset = new OpenLayers.Pixel(this.icon.size.w / 2,
|
var iconPosition = pixel.diff(this.icon.offset);
|
||||||
this.icon.size.h);
|
|
||||||
var iconPosition = pixel.diff(markerOffset);
|
|
||||||
var markerObject = OpenLayers.Util.createImage(this.icon.url,
|
var markerObject = OpenLayers.Util.createImage(this.icon.url,
|
||||||
this.icon.size,
|
this.icon.size,
|
||||||
iconPosition);
|
iconPosition);
|
||||||
|
|||||||
Reference in New Issue
Block a user