如何模拟地理定位服务AS3

时间:2015-07-23 08:08:38

标签: actionscript-3 geolocation

我正在创建一个在手机上使用Geolocation servioce的应用程序o通过互联网发送位置/时间数据。这工作得很好。问题是我无法在Flashdevelop中测试它,因为不支持Geolocation,所以我每次都要上传新代码并在手机上测试它。有没有办法在Flashdevelop中模拟地理定位服务?或者一般来说,在台式电脑上?

1 个答案:

答案 0 :(得分:0)

很抱歉打扰......我发现......很简单的回答是......

private function startLocating():void {
    var myLat:Number=44.2343;
    var myLong:Number=20.9432;
    _geo = new Geolocation();
    _geo.addEventListener(GeolocationEvent.UPDATE, Handler1 );
    if (Geolocation.isSupported) {
        if (!_geo.muted) {
            _geo.setRequestedUpdateInterval(1000);
        } else {
            trace ("Location service not turned on.");
        }
    } else {
        /* this code is working when Geolocation is not supported */
        _geo.dispatchEvent(new GeolocationEvent(GeolocationEvent.UPDATE,false,false,myLat,myLong));
    }
}
private function Handler1(ev:GeolocationEvent):void {
    var latitude:Number = ev.latitude;
    var longitude:Number = ev.longitude;
    .....
}