diff --git a/MapController.js b/MapController.js index 9ed99fc..4a3ec97 100644 --- a/MapController.js +++ b/MapController.js @@ -110,6 +110,18 @@ define([ return this.geoJsonFormatter.writeGeometry(geom); }, + transformBoundingboxToMapExtent: function(boundingbox) { + var lowerleft = this.transformLatLonToPoint(boundingbox.lowerleft.lat, boundingbox.lowerleft.lon); + var upperright = this.transformLatLonToPoint(boundingbox.upperright.lat, boundingbox.upperright.lon); + return ([lowerleft.getCoordinates()[0], lowerleft.getCoordinates()[1], + upperright.getCoordinates()[0], upperright.getCoordinates()[1]]); + }, + + transformLatLonToPoint: function(lat, lon) { + var point = new ol.geom.Point([ lon, lat ]); + return (point.transform('EPSG:4326', 'EPSG:31370')); + }, + _createLayers: function(map) { /* base layers */ var baseLayers = []; diff --git a/ZoneMap.js b/ZoneMap.js index 13af6c6..20da7ed 100644 --- a/ZoneMap.js +++ b/ZoneMap.js @@ -269,6 +269,7 @@ define([ var crabNode = domConstruct.create("div"); ZoomTab.addContent(crabNode); var crabZoomer = crabpyWidget.createCrabZoomer(crabNode); + crabZoomer.startup(); var self = this; var zoomButton = domConstruct.create("a", { @@ -276,18 +277,19 @@ define([ title: "Zoom naar adres", 'class': "button tiny expand", innerHTML: "Zoom naar adres", - onclick: function (evt) { + onclick: lang.hitch(this, function (evt) { evt.preventDefault(); - var bbox = crabZoomer.getBbox(); - if (bbox) { - self.mapController.zoomToExtent(bbox); - if (self.mapController.olMap.getView().getZoom() > 15) { - self.mapController.olMap.getView().setZoom(15); + var bboxobject = crabZoomer.getBbox(); + if (bboxobject) { + var bbox = this.mapController.transformBoundingboxToMapExtent(bboxobject); + this.mapController.zoomToExtent(bbox); + if (this.mapController.olMap.getView().getZoom() > 15) { + this.mapController.olMap.getView().setZoom(15); } crabZoomer.reset(); sidebar.collapse(); } - } + }) }); ZoomTab.addContent(zoomButton); @@ -313,7 +315,7 @@ define([ } if (this.config.sidebar.draw) { - var drawTab = sidebar.createTab('Bepaal zone', 'fa-connectdevelop', 'Bepaal hier de zone.'); + var drawTab = sidebar.createTab('Bepaal zone', 'fa-pencil', 'Bepaal hier de zone.'); /* ZONE */ var zonePane = domConstruct.create('div'); diff --git a/bower.json b/bower.json index bb1d9b8..55aa23b 100644 --- a/bower.json +++ b/bower.json @@ -14,7 +14,7 @@ "dojo": "~1.12.1", "dijit": "~1.12.1", "proj4": "~2.3.15", - "crabpy_dojo": "https://github.com/OnroerendErfgoed/crabpy_dojo.git#1.4.0", + "crabpy_dojo": "https://github.com/OnroerendErfgoed/crabpy_dojo.git#1.4.3", "ol": "https://github.com/OnroerendErfgoed/ol3-amd.git#0.2.1", "font-awesome": "~4.6.3", "dgrid": "~1.1.0",