uni-app 로컬 위도를 통해 상세한 지리적 위치 얻기

4796 단어
 1 uni.getLocation({
 2     type: 'wgs84',
 3     success: function(res) {
 4     console.log(' :' + res.longitude);
 5     console.log(' :' + res.latitude);
 6     var point = new plus.maps.Point(res.longitude, res.latitude);
 7     plus.maps.Map.reverseGeocode(
 8     point,
 9     {},
10     function(event) {
11         var address = event.address; //  
12         var point = event.coord; //  
13         var coordType = event.coordType; //  
14         console.log(address, 'address');
15     },
16     function(e) {}
17                 );
18             }
19         });

 
uni.getLocation({
            type: 'wgs84',
            success: function(res) {
                console.log(' :' + res.longitude);
                console.log(' :' + res.latitude);
                var point = new plus.maps.Point(res.longitude, res.latitude);
                plus.maps.Map.reverseGeocode(
                    point,
                    {},
                    function(event) {
                        var address = event.address; //  
                        var point = event.coord; //  
                        var coordType = event.coordType; //  
                        console.log(address, 'address');
                        var reg = /.+?( | | | | | )/g;
                        
                        console.log(address.match(reg));
                        _this.addressList=address.match(reg).toString().split(",");
                         _this.address= _this.addressList[1];
                        console.log(_this.addressList[0]);
                        console.log(_this.addressList[1]);
                        console.log(_this.addressList[2]);
                        
                    },
                    function(e) {}
                );
            }
        });

 
다음으로 전송:https://www.cnblogs.com/hinux/p/11021999.html

좋은 웹페이지 즐겨찾기