Fix anchor origin calculation

This commit is contained in:
oterral
2014-03-07 13:25:06 +01:00
parent e5fe832839
commit 5028aa3bc3
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -450,7 +450,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
anchorXUnits = ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_; anchorXUnits = ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_;
anchorYUnits = ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_; anchorYUnits = ol.format.KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_;
} else if (/^http:\/\/maps\.(?:google|gstatic)\.com\//.test(src)) { } else if (/^http:\/\/maps\.(?:google|gstatic)\.com\//.test(src)) {
anchor = [0.5, 1]; anchor = [0.5, 0];
anchorXUnits = ol.style.IconAnchorUnits.FRACTION; anchorXUnits = ol.style.IconAnchorUnits.FRACTION;
anchorYUnits = ol.style.IconAnchorUnits.FRACTION; anchorYUnits = ol.style.IconAnchorUnits.FRACTION;
} }
@@ -471,7 +471,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
var imageStyle = new ol.style.Icon({ var imageStyle = new ol.style.Icon({
anchor: anchor, anchor: anchor,
anchorOrigin: ol.style.IconAnchorOrigin.TOP_LEFT, anchorOrigin: ol.style.IconAnchorOrigin.BOTTOM_LEFT,
anchorXUnits: anchorXUnits, anchorXUnits: anchorXUnits,
anchorYUnits: anchorYUnits, anchorYUnits: anchorYUnits,
crossOrigin: 'anonymous', // FIXME should this be configurable? crossOrigin: 'anonymous', // FIXME should this be configurable?
+1 -1
View File
@@ -157,7 +157,7 @@ ol.style.Icon.prototype.getAnchor = function() {
} }
if (this.anchorOrigin_ == ol.style.IconAnchorOrigin.BOTTOM_LEFT || if (this.anchorOrigin_ == ol.style.IconAnchorOrigin.BOTTOM_LEFT ||
this.anchorOrigin_ == ol.style.IconAnchorOrigin.BOTTOM_RIGHT) { this.anchorOrigin_ == ol.style.IconAnchorOrigin.BOTTOM_RIGHT) {
anchor[1] += size[1]; anchor[1] = -anchor[1] + size[1];
} }
} }
return anchor; return anchor;