PanZoomBar is now a subclass of PanZoom, and can drop a lot of its functions in favor of inheriting from that class. hooray for less code duplication.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@83 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -6,18 +6,18 @@
|
||||
//
|
||||
OpenLayers.Control.PanZoomBar = Class.create();
|
||||
OpenLayers.Control.PanZoomBar.prototype =
|
||||
Object.extend( new OpenLayers.Control(), {
|
||||
Object.extend( new OpenLayers.Control.PanZoom(), {
|
||||
// Array(...)
|
||||
buttons: null,
|
||||
|
||||
initialize: function() {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
OpenLayers.Control.PanZoom.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
draw: function() {
|
||||
this.map.events.register("zoomend", this, this.moveZoomBar);
|
||||
// initialize our internal div
|
||||
OpenLayers.Control.prototype.draw.apply(this);
|
||||
this.map.events.register("zoomend", this, this.moveZoomBar);
|
||||
|
||||
// place the controls
|
||||
this.buttons = new Array();
|
||||
@@ -116,78 +116,8 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
slider.style.top = (this.map.getZoomLevels() - this.map.getZoom())*15+
|
||||
parseInt(document.getElementById("OpenLayers_Control_PanZoomBar_Zoombar").style.top) + 3;
|
||||
},
|
||||
_addButton:function(id, img, xy, sz) {
|
||||
var imgLocation = OpenLayers.Util.getImagesLocation() + img;
|
||||
// var btn = new ol.AlphaImage("_"+id, imgLocation, xy, sz);
|
||||
var btn = OpenLayers.Util.createImage(
|
||||
imgLocation, sz, xy, "absolute",
|
||||
"OpenLayers_Control_PanZoomBar_" + id );
|
||||
|
||||
//we want to add the outer div
|
||||
this.div.appendChild(btn);
|
||||
|
||||
btn.onmousedown = this.buttonDown.bindAsEventListener(btn);
|
||||
btn.ondblclick = this.doubleClick.bindAsEventListener(btn);
|
||||
btn.action = id;
|
||||
btn.map = this.map;
|
||||
|
||||
//we want to remember/reference the outer div
|
||||
this.buttons.push(btn);
|
||||
return btn;
|
||||
},
|
||||
|
||||
doubleClick: function (evt) {
|
||||
Event.stop(evt);
|
||||
},
|
||||
|
||||
buttonDown: function (evt) {
|
||||
switch (this.action) {
|
||||
case "panup":
|
||||
var resolution = this.map.getResolution();
|
||||
var center = this.map.getCenter();
|
||||
this.map.setCenter(
|
||||
new OpenLayers.LatLon(center.lat + (resolution * 50),
|
||||
center.lon
|
||||
)
|
||||
);
|
||||
break;
|
||||
case "pandown":
|
||||
var resolution = this.map.getResolution();
|
||||
var center = this.map.getCenter();
|
||||
this.map.setCenter(
|
||||
new OpenLayers.LatLon(center.lat - (resolution * 50),
|
||||
center.lon
|
||||
)
|
||||
);
|
||||
break;
|
||||
case "panleft":
|
||||
var resolution = this.map.getResolution();
|
||||
var center = this.map.getCenter();
|
||||
this.map.setCenter(
|
||||
new OpenLayers.LatLon(center.lat,
|
||||
center.lon - (resolution * 50)
|
||||
)
|
||||
);
|
||||
break;
|
||||
case "panright":
|
||||
var resolution = this.map.getResolution();
|
||||
var center = this.map.getCenter();
|
||||
this.map.setCenter(
|
||||
new OpenLayers.LatLon(center.lat,
|
||||
center.lon + (resolution * 50)
|
||||
)
|
||||
);
|
||||
break;
|
||||
case "zoomin": this.map.zoomIn(); break;
|
||||
case "zoomout": this.map.zoomOut(); break;
|
||||
case "zoomextents": this.map.zoomExtent(); break;
|
||||
}
|
||||
Event.stop(evt);
|
||||
},
|
||||
destroy: function() {
|
||||
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||
for(i=0; i<this.buttons.length; i++) {
|
||||
this.buttons[i].map = null;
|
||||
}
|
||||
OpenLayers.Control.PanZoom.prototype.destroy.apply(this, arguments);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user