//>>built
define("dojox/geo/openlayers/TouchInteractionSupport","dojo/_base/declare dojo/_base/connect dojo/_base/html dojo/_base/lang dojo/_base/event dojo/_base/window".split(" "),function(k,d,g,l,f,h){return k("dojox.geo.openlayers.TouchInteractionSupport",null,{_map:null,_centerTouchLocation:null,_touchMoveListener:null,_touchEndListener:null,_initialFingerSpacing:null,_initialScale:null,_tapCount:null,_tapThreshold:null,_lastTap:null,constructor:function(a){this._map=a;this._centerTouchLocation=new OpenLayers.LonLat(0,
0);a=this._map.div;d.connect(a,"touchstart",this,this._touchStartHandler);d.connect(a,"touchmove",this,this._touchMoveHandler);d.connect(a,"touchend",this,this._touchEndHandler);this._tapCount=0;this._lastTap={x:0,y:0};this._tapThreshold=100},_getTouchBarycenter:function(a){var b=a.touches;a=b[0];var c=null;c=1<b.length?b[1]:b[0];b=g.marginBox(this._map.div);return{x:(a.pageX+c.pageX)/2-b.l,y:(a.pageY+c.pageY)/2-b.t}},_getFingerSpacing:function(a){a=a.touches;var b=-1;2<=a.length&&(b=a[1].pageX-a[0].pageX,
a=a[1].pageY-a[0].pageY,b=Math.sqrt(b*b+a*a));return b},_isDoubleTap:function(a){var b=!1;a=a.touches;if(0<this._tapCount&&1==a.length){var c=a[0].pageX-this._lastTap.x,e=a[0].pageY-this._lastTap.y;c*c+e*e<this._tapThreshold?b=!0:this._tapCount=0}this._tapCount++;this._lastTap.x=a[0].pageX;this._lastTap.y=a[0].pageY;setTimeout(l.hitch(this,function(){this._tapCount=0}),300);return b},_doubleTapHandler:function(a){a=a.touches;var b=g.marginBox(this._map.div);a=this._map.getLonLatFromPixel(new OpenLayers.Pixel(a[0].pageX-
b.l,a[0].pageY-b.t));this._map.setCenter(new OpenLayers.LonLat(a.lon,a.lat),this._map.getZoom()+1)},_touchStartHandler:function(a){f.stop(a);if(this._isDoubleTap(a))this._doubleTapHandler(a);else{var b=this._getTouchBarycenter(a);this._centerTouchLocation=this._map.getLonLatFromPixel(new OpenLayers.Pixel(b.x,b.y));this._initialFingerSpacing=this._getFingerSpacing(a);this._initialScale=this._map.getScale();this._touchMoveListener||(this._touchMoveListener=d.connect(h.global,"touchmove",this,this._touchMoveHandler));
this._touchEndListener||(this._touchEndListener=d.connect(h.global,"touchend",this,this._touchEndHandler))}},_touchEndHandler:function(a){f.stop(a);0==a.touches.length?(this._touchMoveListener&&(d.disconnect(this._touchMoveListener),this._touchMoveListener=null),this._touchEndListener&&(d.disconnect(this._touchEndListener),this._touchEndListener=null)):(a=this._getTouchBarycenter(a),this._centerTouchLocation=this._map.getLonLatFromPixel(new OpenLayers.Pixel(a.x,a.y)))},_touchMoveHandler:function(a){f.stop(a);
var b=this._getTouchBarycenter(a),c=this._map.getLonLatFromPixel(new OpenLayers.Pixel(b.x,b.y));b=c.lon-this._centerTouchLocation.lon;c=c.lat-this._centerTouchLocation.lat;var e=1;2<=a.touches.length&&(e=this._getFingerSpacing(a)/this._initialFingerSpacing,this._map.zoomToScale(this._initialScale/e));a=this._map.getCenter();this._map.setCenter(new OpenLayers.LonLat(a.lon-b,a.lat-c))}})});