Created
September 14, 2012 16:54
-
-
Save noelweichbrodt/3723212 to your computer and use it in GitHub Desktop.
Map Js ESRI View init
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
var _fnRegisterListeners = function(){ | |
//console.log('MapView: register listeners '); | |
dojo.connect( _oSettings['oMapView'], 'onLoad', function() { | |
_oMediator.Publish(_oEvents.navigation['onAllowMapNavigation'],{ | |
action:false | |
}); | |
dojo.connect( _oSettings['oMapView'], 'resize', _oSettings['oMapView'], | |
function(extent, width, height) { | |
//console.log('MapView: on resize fired by map'); | |
_oSettings['oMapView'].resize(); | |
_oMediator.Publish(_oEvents.mapView['onResize'], { | |
extent : extent, | |
width : width, | |
height : height | |
}); | |
}); | |
_oMediator.Publish(_oEvents.mapview['onLoad'], { | |
mapview : _oSettings['oMapView'] | |
}); | |
}); | |
dojo.connect( _oSettings['oMapView'], 'onUpdateStart', function() { | |
if ( _oSettings['oMapView']) { | |
_oMediator.Publish(_oEvents.navigation['onAllowMapNavigation'], { | |
action:false | |
}); | |
_oMediator.Publish(_oEvents.mapview['onUpdateStart'], {}); | |
} | |
}); | |
dojo.connect(_oSettings['oMapView'], 'onUpdateEnd', function() { | |
if ( _oSettings['oMapView']) { | |
_oMediator.Publish(_oEvents.navigation['onAllowMapNavigation'], { | |
action:true | |
}); | |
_oMediator.Publish(_oEvents.mapview['onUpdateEnd'], {}); | |
} | |
}); | |
dojo.connect( _oSettings['oMapView'], 'onMouseMove', function(evt) { | |
var point = esri.geometry.webMercatorToGeographic(evt.mapPoint); | |
_oMediator.Publish(_oEvents.mapview['onMouseMove'], { | |
geoPoint : point, | |
mapPoint : evt.mapPoint | |
}); | |
}); | |
dojo.connect( _oSettings['oMapView'], 'onMouseDrag', function(evt) { | |
var point = esri.geometry.webMercatorToGeographic(evt.mapPoint); | |
_oMediator.Publish(_oEvents.mapview['onMouseDrag'], { | |
geoPoint : point, | |
mapPoint : evt.mapPoint | |
}); | |
}); | |
_oMediator.Subscribe(_oEvents.mapview['onRefresh'], function(message) { | |
$.each( _oSettings['oMapView'].layerIds, function(index, value) { | |
var l = _oSettings['oMapView'].getLayer(value); | |
if (l.isInstanceOf(esri.layers.ArcGISDynamicMapServiceLayer)) { | |
l.refresh(); | |
} | |
}); | |
}); | |
dojo.connect(_oSettings['oMapView'], 'onZoomEnd', function(extent,zoomFactor, anchor, level) { | |
var scale = esri.geometry.getScale(_oSettings['oMapView']); | |
_oSettings['oCurrentExtent'] = _oSettings['oMapView'].extent; | |
_oMediator.Publish(_oEvents.mapview['onZoomEnd'], { | |
scale : scale, | |
extent : extent, | |
zoomFactor : zoomFactor, | |
anchor : anchor, | |
level : level | |
}); | |
}); | |
dojo.connect(_oSettings['oMapView'], 'onLayersAddResult',function(results){ | |
_oMediator.Publish(_oEvents.mapview['onLayersAddResult'], results); | |
}); | |
_oMediator.Subscribe(_oEvents.mapview['onUpdateStart'],function(message){ | |
// console.log('MapView: onUpdateStart'); | |
_oMediator.Core.showBusyIndicator(); | |
}) | |
_oMediator.Subscribe(_oEvents.mapview['onUpdateEnd'],function(message){ | |
// console.log('MapView: onUpdateEnd') | |
_oMediator.Core.hideBusyIndicator(); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment