Custom knockout.js bindings for ESRI Javascript API widgets (currently just the map widget).
<div id="map" data-bind="esriMap: { mapObject: mapWidget, isLoaded: isMapLoaded,
extent: currentMapExtent, layers: mapLayers, onClick: doSomething }"></div>
<script type="text/javascript">
var viewModel = {
mapWidget: ko.observable(),
isMapLoaded: ko.observable(),
currentMapExtent: ko.observable(),
mapLayers: ko.observableArray([]),
doSomething: function () {
alert('i did it');
}
};
</script>
Parameters are all optional.
mapObject: esri.Map, ESRI map widget
isLoaded: boolean, true if map has successfully loaded with at least 1 layer
extent: esri.geometry.Extent, current map extent (intended for reading only)
layers: array of esri.layers.Layer, current map layers, push to array to add layers to the map
onClick: command to fire on map click, args are identical to esri.map onClick event