Skip to content

Instantly share code, notes, and snippets.

@dbouwman
Created March 21, 2013 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbouwman/5215657 to your computer and use it in GitHub Desktop.
Save dbouwman/5215657 to your computer and use it in GitHub Desktop.
Snipped of the EsriMapModule showing the new event handlers, and
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