Created
March 21, 2013 18:56
-
-
Save dbouwman/5215657 to your computer and use it in GitHub Desktop.
Snipped of the EsriMapModule showing the new event handlers, and
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initMap: function (mapConfig) { | |
console.log('Map:Controller:initMap'); | |
var initialExtent = new esri.geometry.Extent(mapConfig.initialExtent); | |
this.map = new esri.Map("map", { | |
extent: initialExtent, | |
maxZoom: 15 | |
}); | |
dojo.connect(this.map, 'onLoad', this.onMapLoad); | |
//----- NEW EVENT HANDLERS ---------- | |
dojo.connect(this.map, 'onZoomEnd', this.updateUrl); | |
dojo.connect(this.map, 'onPanEnd', this.updateUrl); | |
//--------------- | |
this.initBaseLayers(mapConfig.basemaps); | |
this.initOperationalLayers(mapConfig.operationalLayers); | |
}, | |
updateUrl: function(){ | |
//fires when the extent is updated | |
var center = this.map.geographicExtent.getCenter(); | |
var level = this.map.getLevel(); | |
var data = {x:center.x, y:center.y, l: level}; | |
console.log('EsriMapModule: Extent updated - calling Router:SetUrl with ' + data.x + ' ' +data.y); | |
//raise an event which keeps the map decoupled from the router | |
Viewer.vent.trigger('Router:SetUrl',data); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment