aboutsummaryrefslogtreecommitdiffstats
path: root/www/js/map-OpenLayers.js
diff options
context:
space:
mode:
authorMark Longair <mhl@pobox.com>2012-11-02 11:48:19 +0000
committerMark Longair <mhl@pobox.com>2012-11-02 12:31:24 +0000
commitd74100897c5c35a34afffdced71a5695c1149086 (patch)
tree8b4f04e04a0957eac1fc07b0b9229d2e90ae5cf1 /www/js/map-OpenLayers.js
parent35f12a197f6dc89c9ac5dc1489c5755a3190a454 (diff)
Add a crosshairs control and "mark here" link
Diffstat (limited to 'www/js/map-OpenLayers.js')
-rw-r--r--www/js/map-OpenLayers.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/www/js/map-OpenLayers.js b/www/js/map-OpenLayers.js
index e64ff55..c845978 100644
--- a/www/js/map-OpenLayers.js
+++ b/www/js/map-OpenLayers.js
@@ -206,6 +206,7 @@ function fixmystreet_onload() {
}
});
+ fixmystreet.map.addControl( new OpenLayers.Control.Crosshairs(null) );
}
$(function(){
@@ -309,6 +310,48 @@ $(function(){
}
});
+OpenLayers.Control.Crosshairs = OpenLayers.Class.create();
+OpenLayers.Control.Crosshairs.CROSSHAIR_SIDE = 100;
+OpenLayers.Control.Crosshairs.DIV_ID = "OpenLayers_Control_Crosshairs_crosshairs";
+OpenLayers.Control.Crosshairs.prototype =
+ OpenLayers.Class.inherit( OpenLayers.Control, {
+ element: null,
+ position: null,
+
+ initialize: function(element) {
+ OpenLayers.Control.prototype.initialize.apply(this, arguments);
+ this.element = OpenLayers.Util.getElement(element);
+ this.imageSize = new OpenLayers.Size(OpenLayers.Control.Crosshairs.CROSSHAIR_SIDE,
+ OpenLayers.Control.Crosshairs.CROSSHAIR_SIDE);
+ },
+
+ draw: function() {
+ var position;
+ OpenLayers.Control.prototype.draw.apply(this, arguments);
+ position = this.getIdealPosition();
+ this.buttons = new Array();
+ var imgLocation = OpenLayers.Util.getImagesLocation() + "crosshairs-100.png";
+ return OpenLayers.Util.createAlphaImageDiv(OpenLayers.Control.Crosshairs.DIV_ID,
+ position, this.imageSize, imgLocation, "absolute");
+ },
+
+ getIdealPosition: function() {
+ this.map.updateSize();
+ var mapSize = this.map.getSize();
+ return new OpenLayers.Pixel((mapSize.w / 2) - (this.imageSize.w / 2),
+ (2 * mapSize.h / 5) - (this.imageSize.h / 2));
+ },
+
+ reposition: function() {
+ var position = this.getIdealPosition();
+ $('#' + OpenLayers.Control.Crosshairs.DIV_ID).css({
+ left: position.x,
+ top: position.y});
+ },
+
+ CLASS_NAME: "OpenLayers.Control.Crosshairs"
+});
+
/* Overridding the buttonDown function of PanZoom so that it does
zoomTo(0) rather than zoomToMaxExtent()
*/