_jsload_('AMap.Geolocation', 'g.Vn=g.da.extend({ka:[g.va],Ni:".amap-geolocation-con .amap-geo{background:#fff url(../../theme/v1.3/markers/b/loc_gray.png) 50% 50% no-repeat;width:35px;height:35px;border:1px solid #ccc;border-radius:3px;right:4px}.amap-locate-loading .amap-geo{background-image:url(../../theme/v1.3/loading.gif)}.amap-locate{position:absolute;width:18px;height:18px;background:url(../../theme/v1.3/map_view.png);_background:url(../../theme/v1.3/map_view.gif);background-position:-130px -185px;cursor:pointer}",A:function(a){this.CLASS_NAME= "AMap.Geolocation";g.c.ya(this,a);this.options={enableHighAccuracy:!1,timeout:5E3,maximumAge:0,GeoLocationFirst:!1,convert:!0,convertUrl:g.o.fd+"/v3/assistant/coordinate/convert?coordsys=gps&output=json&s=rsv3&locations={x},{y}&key="+g.o.key,showButton:!0,buttonDom:\'
\',buttonPosition:"LB",buttonOffset:new g.H(10,20),showMarker:!0,markerOptions:{innerOverlay:!0,offset:new g.H(-11,-11),content:" "},showCircle:!0,circleOptions:{innerOverlay:!0,strokeColor:"#0093FF",noSelect:!0,strokeOpacity:0.5,strokeWeight:1,fillColor:"#02B0FF",fillOpacity:0.25},panToLocation:!0,zoomToAccuracy:!1,noIpLocate:0,noGeoLocation:0,useNative:!1,extensions:"base",stopWhenPermissionDenied:!0};if(a)for(var b in a)b in this.options&&(this.options[b]=a[b]);switch(this.options.noGeoLocation){case 0:this.kA=!0;break;case 1:this.kA=!g.l.ba;break;case 2:this.kA=g.l.ba;break;case 3:this.kA=!1;break; default:this.kA=!0}switch(this.options.noIpLocate){case 0:this.Ew=!0;break;case 1:this.Ew=!g.l.ba;break;case 2:this.Ew=g.l.ba;break;case 3:this.Ew=!1;break;case !0:this.Ew=!1;break;default:this.Ew=!0}this.Lb=this.Tb=this.MM=this.rx=this.hi=this.e=null;this.bY=g.event.addListener(this,"complete",this.Mua,this);this.uY=g.event.addListener(this,"error",this.Nua,this)},isSupported:function(){return!!navigator.geolocation},Ul:function(a){new g.kb.Ab(g.o.Cc+"://webapi.amap.com/count?"+["type=loc","k="+ g.o.key,"u="+g.o.Ao,"m="+(g.l.ba?1:0),"pf="+g.l.Fz,"suc="+a].join("&"))},Gqa:function(a){function b(b){b.status=1;d.Lv(b,function(b,c){c.info="SUCCESS";a&&a("complete",c);g.event.O(d,"complete",c)})}function c(b){function c(f){f.message=b.message+f.message;f.status=1;d.Lv(f,function(b,c){c.info="SUCCESS";a&&a("complete",c);g.event.O(d,"complete",c)})}function h(c){b.message+=c.message;b.info="FAILED";b.status=0;a&&a("error",b);g.event.O(d,"error",b)}d.kA?d.i4(c,h):h({message:"GeoLocation is closed by noGeoLocation option,pass Geolocation."})} var d=this;d.Ew?d.n4(b,c):c({message:"IpLocation is closed by noIpLocate option,pass IpLocation."})},i4:function(a,b){if(this.isSupported()){var c=this;g.a.HR(function(d,e){if(d)c.Ul("err"),b({message:d?d.message:""});else{var f=setTimeout(function(){f=null;b({message:"Get geolocation time out."});c.Ul("waitetimeout");h=!0},c.options.timeout),h=!1;e.getCurrentPosition(function(d){if(!h)if(clearTimeout(f),d.coords&&d.coords.longitude){c.Ul("success");d={position:new g.U(d.coords.longitude,d.coords.latitude), location_type:"html5",message:"Get geolocation success.",accuracy:d.coords.accuracy};var e=!1;g.l.Q3&&(e=!0);c.options.convert?e?(d.isConverted=!0,d.message+="Don\'t need convert.",a(d)):c.sI(d,function(b){a(b)}):(e?(d.message+="Don\'t need convert.",d.isConverted=!0):(d.isConverted=!1,d.message+="convert option is false,pass convert."),a(d))}else c.Ul("failed"),b({code:2,info:"POSITION_UNAVAILABLE",message:"Get geolocation failed."})},function(a){h||(clearTimeout(f),1===a.code?(a={code:1,info:"PERMISSION_DENIED", message:"Geolocation permission denied."},c.Ul("denied"),b(a)):3===a.code?(a={code:3,info:"TIME_OUT",message:"Get geolocation time out."},c.Ul("timeout"),b(a)):2===a.code&&(a={code:3,info:"POSITION_UNAVAILABLE",message:"Get geolocation failed."},c.Ul("failed"),b(a)))},this.options)}},{timeout:c.options.timeout})}else b({message:"Browser not Support html5 geolocation."})},sI:function(a,b){var c=a.position,c=this.options.convertUrl.replace("{x}",c.R).replace("{y}",c.Q);g.o.Xa&&(c+="&jscode="+g.o.Xa); c=new g.kb.Ab(c,{callback:"callback"});g.event.addListener(c,"complete",function(c){1===parseInt(c.status)&&c.locations?(c=c.locations.split(","),c=new g.U(parseFloat(c[0]),parseFloat(c[1])),a.position=c,a.isConverted=!0,a.message+="Convert Success."):(a.isConverted=!1,a.message+="Convert failed.");b(a)},this);g.event.addListener(c,"error",function(){a.message+="Convert request failed.";a.isConverted=!1;b(a)},this)},n4:function(a,b){var c=new g.kb.Ab(g.o.Cc+"://webapi.amap.com/maps/ipLocation?key="+ g.o.key,{callback:"callback"});c.h("complete",function(c){c.status&&c.lng&&c.lat?(c.position=g.a.Loa(c.lng,c.lat),delete c.lng,delete c.lat,c.message="Get ipLocation success.",c.location_type="ip",c.accuracy=null,c.isConverted=!0,a(c)):b({message:"Get ipLocation failed."})},this);c.h("error",function(){b({message:"Request ipLocation failed."})},this)},Fqa:function(a){function b(b){function e(e){e.message=b.message+e.message;e.status=1;c.Lv(e,function(b,d){d.info="SUCCESS";a&&a("complete",d);g.event.O(c, "complete",d)})}function f(e){b.message+=e.message;if(1===e.code)b.info="FAILED",b.status=0,a&&a("error",b),g.event.O(c,"error",b);else{e=function(e){b.message+=e.message;b.info="FAILED";b.status=0;a&&a("error",b);g.event.O(c,"error",b)};var f=function(e){e.status=1;e.message=b.message+e.message;c.Lv(e,function(b,d){d.info="SUCCESS";a&&a("complete",d);g.event.O(c,"complete",d)})};c.Ew?c.n4(f,e):e({message:"IpLocation is closed by noIpLocate option,pass ipLocation."})}}c.kA?c.i4(e,f):f({message:"Geolocation is closed by noGeoLocation option,pass Geolocation."})} var c=this;this.options.useNative&&g.l.Zl?this.Sta(function(b){b.status=1;c.Lv(b,function(b,d){d.info="SUCCESS";a&&a("complete",d);g.event.O(c,"complete",d)})},function(a){b(a)}):b({message:""})},getCurrentPosition:function(a){g.c.add(this,"getCurrentPosition");this.jO=!0;g.f.Wa(this.hi,"amap-locate-loading");g.l.ba||this.options.GeoLocationFirst?this.Fqa(a):this.Gqa(a)},getCityInfo:function(a){g.c.add(this,"getCityInfo");var b=new g.kb.Ab(g.o.Cc+"://webapi.amap.com/maps/ipCity?key="+g.o.key,{callback:"callback"}); b.h("complete",function(b){b.center&&1===b.status?(b.isConverted=!0,b.info="SUCCESS",b.message="Get city by ip success.",a&&a("complete",b)):(b.info="FAILED",b.message="Get city by ip failed.",a&&a("error",b))},this);b.h("error",function(){a&&a("error",{status:0,message:"Request ipCity failed.",info:"FAILED"})},this)},watchPosition:function(){if(this.options.useNative&&window.AMapAndroidLoc)this.bAa();else if(g.c.add(this,"watchPosition"),this.isSupported()){if(g.l.ba){var a=this;return g.a.HR(function(b, c,d){if(b)g.event.O(a,"error",{status:0,info:"FAILED",message:"Get geolocation error on watch."});else return b=c.watchPosition(function(b){if(b.coords&&b.coords.longitude){b={position:new g.U(b.coords.longitude,b.coords.latitude),location_type:"html5",message:"Watch position success by GeoLocation.",status:1,accuracy:b.coords.accuracy};var c=!1;g.l.Q3&&(c=!0);var d=function(b){a.Lv(b,function(b,c){c.info="SUCCESS";g.event.O(a,"complete",c)})};a.options.convert?c?(b.message+="Don\'t need convert.", b.isConverted=!0,d(b)):a.sI(b,function(a){d(a)}):(c?(b.message+="Don\'t need convert.",b.isConverted=!0):(b.message+="convert option is false,pass convert.",b.isConverted=!1),d(b))}else g.event.O(a,"error",{status:0,info:"FAILED",message:"Watch position failed by GeoLocation,incorrect position."})},function(){g.event.O(a,"error",{status:0,info:"FAILED",message:"Watch position failed by GeoLocation."})},a.options),d&&g.a.Kxa(d,b),b},{Zza:!0})}g.event.O(this,"error",{status:0,info:"NOT_SUPPORT",message:"Forbidden watchPosition on PC device."})}else return g.event.O(this, "error",{status:0,info:"NOT_SUPPORT",message:"Browser not Support html5 GeoLocation."}),null},clearWatch:function(a){g.c.add(this,"clearWatch");if(this.options.useNative&&window.AMapAndroidLoc)g.Vn.Mw.Bi.kya(this);else if(this.isSupported())return g.a.HR(function(b,c){b||g.a.Yza(a,function(b,e){b||(g.a.Ina(a),c.clearWatch(e))})})},zu:function(a,b){if(!this.hi){var c=document.createElement("div");this.jO&&g.f.Wa(c,"amap-locate-loading");g.f.Wa(c,"amap-geolocation-con");"object"===typeof this.options.buttonDom? c.appendChild(this.options.buttonDom):c.innerHTML=this.options.buttonDom;c.style.position="absolute";c.style.zIndex="9999";this.options.showButton||(c.style.visibility="hidden");this.cC(c,this.options.buttonPosition,this.options.buttonOffset);this.hi=c}this.e=a;b.appendChild(this.hi);this.rx=b;this.MM=g.event.Y(this.hi,"click",this.Lua,this)},Yv:function(){g.event.removeListener(this.bY);this.bY=null;g.event.removeListener(this.uY);this.uY=null;g.event.removeListener(this.MM);this.MM=null;this.rx.removeChild(this.hi); this.e=this.rx=null;this.Tb&&(this.Tb.setMap(null),this.Tb=null);this.Lb&&(this.Lb.setMap(null),this.Lb=null)},cC:function(a,b,c){"LT"!==b&&"RT"!==b&&"LB"!==b&&"RB"!==b&&(b="LT");switch(b){case "LT":g.f.ab(a,{left:c.x+"px",top:c.y+"px",right:"",bottom:""});break;case "RT":g.f.ab(a,{right:c.x+"px",top:c.y+"px",left:"",bottom:""});break;case "LB":g.f.ab(a,{left:c.x+"px",bottom:c.y+"px",right:"",top:""});break;case "RB":g.f.ab(a,{right:c.x+"px",bottom:c.y+"px",left:"",top:""})}this.rx&&(this.rx.removeChild(a), this.rx.appendChild(a))},Yxa:function(a,b){if(this.e){var c=this.options;c.showMarker&&(this.Tb||(this.Tb=new z.B.wb(c.markerOptions),this.Tb.Da=!0),this.Tb.setPosition(a),this.Tb.setMap(this.e));c.showCircle&&(this.Lb||(this.Lb=new z.B.hh(c.circleOptions)),this.Lb.setCenter(a),this.Lb.setRadius(b||0),this.Lb.setMap(this.e),this.Lb.Da=!0);c.panToLocation&&this.e.panTo(a);c.zoomToAccuracy&&this.Lb&&this.e.setFitView([this.Lb])}},aFa:function(){this.Tb&&this.Tb.setMap(null);this.Lb&&this.Lb.setMap(null)}, Lv:function(a,b){var c=this,d=a.position;g.ub.load("AMap.Geocoder",function(){c.R3||(c.R3=new g.lW({extensions:c.options.extensions}));c.R3.getAddress(d,function(c,d){"complete"===c?(g.extend(a,d.regeocode),a.message+="Get address success."):a.message+="Get address fail,check your key or network.";b("complete",a)})})},Lua:function(){this.getCurrentPosition()},Mua:function(a){this.jO=!1;g.f.fb(this.hi,"amap-locate-loading");this.Yxa(a.position,a.accuracy)},Nua:function(){this.jO=!1;g.f.fb(this.hi, "amap-locate-loading")},Sta:function(a,b){function c(a){1!==a&&d.Ul("sdkerror");b&&b.call&&b.call(d,{message:"Get sdkLocation failed."})}if(window.AMapAndroidLoc)this.Tta(a,b);else{var d=this,e=new g.kb.Ab("http://127.0.0.1:43689/geolocation?to=3000&_="+(new Date).getTime(),{callback:"callback"});e.h("complete",function(b){a&&a.call&&b.location&&b.location.x&&b.location.y?(a.call(d,{position:new g.U(b.location.x,b.location.y),accuracy:b.location.precision,message:"Get sdkLocation success.",location_type:"sdk", isConverted:!0}),d.Ul("sdksuccess")):(c(1),d.Ul("sdkfail"))});e.h("error",c)}},Tta:function(a,b){var c=this;g.Vn.Mw.Bi.fra(this,function(d){a&&a.call&&d.result&&d.result.x&&d.result.y?(a.call(c,{position:new g.U(d.result.x,d.result.y),accuracy:d.result.precision,message:"Get sdkLocation success.",location_type:"sdk",isConverted:!0}),c.Ul("sdksuccess")):(b&&b.call&&b.call(c,{sdkErrorInfo:d.errorInfo,sdkLocationDetail:d.locationDetail,message:"Get sdkLocation failed."}),c.Ul("sdkfail"))})},bAa:function(){var a= this;g.Vn.Mw.Bi.aAa(this,function(b){b.result&&b.result.x&&b.result.y?(b={position:new g.U(b.result.x,b.result.y),location_type:"sdk",message:"Watch position success by Android SDK.",status:1,accuracy:b.result.precision},b.message+="Don\'t need convert.",b.isConverted=!0,function(b){a.Lv(b,function(b,c){c.info="SUCCESS";g.event.O(a,"complete",c)})}(b)):g.event.O(a,"error",{status:0,info:"FAILED",message:"Watch position failed by Android SDK,incorrect position."})})}});window.AMap.Geolocation=g.Vn; g.Vn.cbk=function(a){a=JSON.parse(a);var b=g.Vn.Mw.Bi;b.r("get",a);b.r("watch",a)}; g.Vn.Mw=g.da.extend({ka:[g.va],A:function(){},fra:function(a,b){var c=window.AMapAndroidLoc;this.h("get",b,a,!0);this.we("watch")||c.getLocation(JSON.stringify({to:a.options.timeout,useGPS:1,watch:0,callback:"AMap.Geolocation.cbk"}))},aAa:function(a,b){this.we("watch")||window.AMapAndroidLoc.getLocation(JSON.stringify({to:a.options.timeout,useGPS:1,watch:1,interval:a.options.watchInterval||5,callback:"AMap.Geolocation.cbk"}));this.h("watch",b,a)},kya:function(a){var b=window.AMapAndroidLoc;this.fK("watch", a);this.we("watch")||b.stopLocation()}});g.Vn.Mw.Bi=new g.Vn.Mw; ')