nettes kleines Tutorial<\/A> zum Arbeiten mit Dojo-Animationen.<\/P>Hier ist der Quellcode für das TouchWidget<\/P>
define([
'esri\/layers\/GraphicsLayer',
'esri\/graphic',
'esri\/symbols\/SimpleMarkerSymbol',
'dojo\/on', 'dojo\/fx', 'dojo\/_base\/fx', 'dojo\/fx\/easing',
'dojo\/aspect', 'dojo\/_base\/Color',
'dojo\/_base\/declare', 'dojo\/_base\/lang',
'dijit\/_WidgetBase', 'dijit\/a11yclick'
], function(
GraphicsLayer, Graphic, SimpleMarkerSymbol,
on, fx, coreFx, easing, aspect, Color,
declare, lang, _WidgetBase, a11yclick
) {
'use strict';
var hitch = lang.hitch;
return declare([_WidgetBase], {
postCreate: function() {
this.set('delay', this.settings.delay || 500);
this._symInner = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, this.settings.innerSize, null, new Color(this.settings.innerColor));
this._symOuter = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, this.settings.outerSize, null, new Color(this.settings.outerColor));
this.touchLayer = new GraphicsLayer();
},
startup: function() {
if (!this.map) {
this.destroy();
throw new Error('Must provide a map object to use TouchWidget');
}
if (this.map.loaded) {
this._init();
} else {
on.once(this.map, 'load', hitch(this, '_init'));
},
\/\/- widget methods
_fxArgs: function(graphic) {
return {
node: graphic.getNode(),
duration: this.delay,
easing: easing.expoOut
};
 .& nbsp ;},
& nbsp ;& nbsp ;_fxToCombine: function(graphicOuter , graphicInner) {
& nbsp ;& nbsp ;& nbsp ;& nbsp ;return [
& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;coreFx.fadeOut(this._fxArgs(graphicOuter)),
& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;coreFx.fadeOut(this._fxArgs(graphicInner))
& nbsp ;& nbsp ;& nbsp ;& nbsp ;];
& nbsp ;& nbsp ;},
& nbsp ;& nbsp ;_onAspectAfterEnd: function(graphicOuter , graphicInner) {
& nbsp ;& nbsp ;& nbsp ;& nbsp ;return lang.hitch(this , function() {
& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;this.touchLayer.remove(graphicOuter);
& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ;this.touchLayer.remove(graphicInner);
& nbsp ;& nbsp ;& nbsp ;& nbsp ;});
& nbsp ;& nbsp ;},
& nbsp ;& nbsp ;_onTimeOut: function(graphicOuter , graphicInner) {
& nbsp ;& nbsp ;& nbsp ;& nbsp ;return hitch(this , function() {
& nbsp ;& nbsp ;& nb sp;; & nb sp;; var combined = this._fxToCombine(graphicOuter , graphicInner);
& nb sp;; & nb sp;; & nb sp;; var f = fx.combine(combined);
& nb sp;; & nb sp;; & nb sp;; this.own(aspect.after(f , 'onEnd' , hitch(this , this._onAspectAfterEnd(graphicOuter , graphicInner))));
& nb sp;; & nb sp;; & nb sp;; f.play();
& nb sp;; & nb sp;; });
& nb sp;;},
& nb sp;;_onTouchClick: function(e) {
& nb sp;; & nb sp;; var graphicOuter = new Graphic(e.mapPoint , this._symOuter);
& nb sp;; & nb sp;; var graphicInner = new Graphic(e.mapPoint , this._symInner);
& nb sp;; & nb sp;; this.touchLayer.add(graphicOuter);
& nb sp;; & nb sp;; this.touchLayer.add(graphicInner);
& nb sp;; & nb sp;; setTimeout(hitch(this , this._onTimeOut(graphicOuter , graphicInner)) , this.delay);
& nb sp;;},
& nb sp;; \/\/- private methods
& nb sp;;_init: function() {
& nb sp;; & nb sp;; this.map.addLayer(this.touchLayer);
& nb sp;; & nb sp;; this.set('loaded' , true);
& nb sp;; & nb sp;; this.emit('load' , {});
& nb sp;; & nb sp;; \/\/- set up touch handlers
& nb sp;; & nb sp;; this.own(on(this.get('map') , a11yclick.click , hitch(this , '_onTouchClick')));
& nb sp;;}
});
});<\/PRE><\/P>Was dieses Widget macht, ist das Einrichten eines inneren und äußeren Grafiksymbols. Die Größe dieser Symbole kann über die an das Widget übergebenen Parameter definiert werden. Es fügt auch seine eigene Ebene hinzu, um diese Features anzuzeigen, sodass Sie sich keine Sorgen machen müssen über Konflikte mit dem Standard-GraphicsLayer der Karte.<\/P><\/P>