修复定位精度问题, 全部采用系统定位
This commit is contained in:
parent
a23c9b3e46
commit
6817d15b7e
@ -2,8 +2,8 @@
|
||||
"name" : "惠农生活",
|
||||
"appid" : "__UNI__3A527D1",
|
||||
"description" : "",
|
||||
"versionName" : "1.7.1",
|
||||
"versionCode" : 171,
|
||||
"versionName" : "1.7.2",
|
||||
"versionCode" : 172,
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
"app-plus" : {
|
||||
|
@ -107,7 +107,8 @@
|
||||
} from "vuex";
|
||||
import {
|
||||
goShopDetail
|
||||
} from '@/libs/order.js'
|
||||
} from '@/libs/order.js';
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
const app = getApp();
|
||||
export default {
|
||||
data() {
|
||||
@ -273,6 +274,7 @@
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
longitude = res.longitude.toString();
|
||||
|
@ -54,6 +54,7 @@
|
||||
</template>
|
||||
<script>
|
||||
import home from '@/components/home/index.vue'
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
|
||||
import {
|
||||
getlevelInfo,
|
||||
@ -135,6 +136,7 @@
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
try {
|
||||
this.user_latitude = res.latitude;
|
||||
this.user_longitude = res.longitude;
|
||||
|
@ -239,6 +239,7 @@
|
||||
storeMerchantList,
|
||||
getGeocoder
|
||||
} from '@/api/store.js';
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
import {
|
||||
initiateAssistApi
|
||||
} from '@/api/activity.js';
|
||||
@ -476,8 +477,9 @@
|
||||
let self = this
|
||||
if (uni.getStorageSync('RejectTarget')) return
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
// console.log(res)
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
|
@ -87,6 +87,7 @@
|
||||
|
||||
<script>
|
||||
import Cache from '@/utils/cache';
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
import mTabbar from '@/components/m-tabbar/m-tabbar.vue'
|
||||
import zbpSwiper from '@/components/zbpSwiper'
|
||||
import {
|
||||
@ -453,6 +454,7 @@
|
||||
type: 'wgs84',
|
||||
timeout: '10',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
// console.log(res)
|
||||
this.isshow = false
|
||||
let latitude, longitude;
|
||||
|
@ -52,6 +52,7 @@
|
||||
|
||||
<script>
|
||||
import mTabbar from '@/components/m-tabbar/m-tabbar.vue'
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
import zbpSwiper from '@/components/zbpSwiper'
|
||||
import {
|
||||
getSlideAPI
|
||||
@ -224,8 +225,9 @@
|
||||
},
|
||||
selfLocation() {
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
longitude = res.longitude.toString();
|
||||
|
@ -115,6 +115,7 @@
|
||||
|
||||
<script>
|
||||
import mTabbar from '@/components/m-tabbar/m-tabbar.vue'
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
import zbpSwiper from '@/components/zbpSwiper'
|
||||
import easyLoadimage from '@/components/easy-loadimage/easy-loadimage.vue';
|
||||
import WaterfallsFlow from '@/components/WaterfallsFlow/WaterfallsFlows.vue'
|
||||
@ -665,6 +666,7 @@
|
||||
type: 'wgs84',
|
||||
timeout: '1000',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
console.log('定位成功', res);
|
||||
this.isshow = false
|
||||
let latitude, longitude;
|
||||
|
@ -185,6 +185,7 @@
|
||||
getStoreList,
|
||||
getGeocoder,
|
||||
} from '@/api/store.js';
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
import {
|
||||
supMenuApi
|
||||
} from '@/api/requesta.js';
|
||||
@ -626,8 +627,9 @@
|
||||
this.getStoreList();
|
||||
})
|
||||
} else uni.getLocation({
|
||||
type: 'gcj02',
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
console.log('定位');
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
|
@ -183,6 +183,7 @@
|
||||
getStoreList,
|
||||
getGeocoder,
|
||||
} from '@/api/store.js';
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
import {
|
||||
supMenuApi
|
||||
} from '@/api/requesta.js';
|
||||
@ -625,8 +626,9 @@
|
||||
this.getStoreList();
|
||||
})
|
||||
} else uni.getLocation({
|
||||
type: 'gcj02',
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
console.log('定位');
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
|
@ -536,8 +536,9 @@
|
||||
if (uni.getStorageSync('RejectTarget')) return
|
||||
let self = this
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
longitude = res.longitude.toString();
|
||||
|
@ -280,6 +280,7 @@
|
||||
supMenuApi,
|
||||
supAgoodsApi
|
||||
} from '@/api/store.js';
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
|
||||
import {
|
||||
merClassifly,
|
||||
@ -540,8 +541,9 @@
|
||||
let self = this
|
||||
if (uni.getStorageSync('RejectTarget')) return
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
longitude = res.longitude.toString();
|
||||
|
@ -352,6 +352,7 @@
|
||||
storeMerchantList,
|
||||
getGeocoder,
|
||||
} from '@/api/store.js';
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
import {
|
||||
supMenuApi
|
||||
} from '@/api/requesta.js';
|
||||
@ -819,9 +820,10 @@
|
||||
})
|
||||
}
|
||||
else uni.getLocation({
|
||||
type: 'gcj02',
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
console.log('定位');
|
||||
res = wgsToGcj(res);
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
longitude = res.longitude.toString();
|
||||
|
@ -284,6 +284,7 @@
|
||||
|
||||
supAgoodsApi
|
||||
} from '@/api/store.js';
|
||||
import { wgsToGcj } from "@/utils/wgs.js";s
|
||||
import {
|
||||
supMenuApi,
|
||||
} from '@/api/requesta.js';
|
||||
@ -597,8 +598,9 @@
|
||||
})
|
||||
}
|
||||
else uni.getLocation({
|
||||
type: 'gcj02',
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
longitude = res.longitude.toString();
|
||||
|
@ -189,6 +189,7 @@
|
||||
storeMerchantList,
|
||||
getGeocoder,
|
||||
} from '@/api/store.js';
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
import {
|
||||
supMenuApi,
|
||||
getCategoryListLevel
|
||||
@ -663,9 +664,10 @@
|
||||
})
|
||||
}
|
||||
else uni.getLocation({
|
||||
type: 'gcj02',
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
console.log('定位');
|
||||
res = wgsToGcj(res);
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
longitude = res.longitude.toString();
|
||||
|
@ -197,6 +197,7 @@
|
||||
storeMerchantList,
|
||||
getGeocoder
|
||||
} from '@/api/store.js';
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
import recommend from './component/recommend';
|
||||
import rightSlider from './component/rightSlider';
|
||||
import {
|
||||
@ -460,8 +461,9 @@
|
||||
selfLocation() {
|
||||
let self = this
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
longitude = res.longitude.toString();
|
||||
|
@ -279,6 +279,7 @@
|
||||
supMenuApi,
|
||||
supAgoodsApi
|
||||
} from '@/api/store.js';
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
|
||||
import {
|
||||
merClassifly,
|
||||
@ -537,8 +538,9 @@
|
||||
let self = this
|
||||
if (uni.getStorageSync('RejectTarget')) return
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
longitude = res.longitude.toString();
|
||||
|
@ -182,6 +182,7 @@
|
||||
|
||||
Toast
|
||||
} from '@/libs/uniApi.js'
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
import {
|
||||
merchantUpdateAPI,
|
||||
merchantInfoAPI
|
||||
@ -425,6 +426,7 @@
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
// console.log(res);
|
||||
this.latitude = res.latitude.toString();
|
||||
this.longitude = res.longitude.toString();
|
||||
|
@ -62,6 +62,7 @@
|
||||
merClassifly,
|
||||
getProductslist
|
||||
} from '@/api/store.js';
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
import {
|
||||
getArea,
|
||||
getStreet
|
||||
@ -112,6 +113,7 @@
|
||||
type: 'wgs84',
|
||||
timeout: '10',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
longitude = res.longitude.toString();
|
||||
|
@ -65,6 +65,7 @@
|
||||
getStreet
|
||||
} from "@/api/article.js";
|
||||
import { Toast } from '@/libs/uniApi';
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -118,6 +119,7 @@
|
||||
type: 'wgs84',
|
||||
timeout: '4',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
longitude = res.longitude.toString();
|
||||
|
@ -186,6 +186,7 @@
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
import { storeMerchantList, getGeocoder } from '@/api/store.js';
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
import recommend from '@/components/recommend';
|
||||
import rightSlider from '@/components/rightSlider/index';
|
||||
import { merClassifly, getStoreTypeApi } from '@/api/store.js';
|
||||
@ -418,8 +419,9 @@
|
||||
selfLocation() {
|
||||
let self = this
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
success: (res) => {
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
longitude = res.longitude.toString();
|
||||
|
@ -174,6 +174,7 @@
|
||||
|
||||
<script>
|
||||
import mTabbar from '@/components/m-tabbar/m-tabbar.vue'
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
import zbpSwiper from '@/components/zbpSwiper'
|
||||
import easyLoadimage from '@/components/easy-loadimage/easy-loadimage.vue';
|
||||
import WaterfallsFlow from '@/components/WaterfallsFlow/WaterfallsFlowo.vue'
|
||||
@ -646,6 +647,7 @@ import { data } from '../../uni_modules/uview-ui/libs/mixin/mixin';
|
||||
type: 'wgs84',
|
||||
timeout: '10',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
this.isshow = false
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
|
@ -59,6 +59,7 @@
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
import Loading from "@/components/Loading";
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
import {
|
||||
storeListApi
|
||||
} from "@/api/store";
|
||||
@ -165,6 +166,7 @@
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
success: function(res) {
|
||||
res = wgsToGcj(res);
|
||||
try {
|
||||
uni.setStorageSync('user_latitude', res.latitude);
|
||||
uni.setStorageSync('user_longitude', res.longitude);
|
||||
|
@ -86,6 +86,7 @@
|
||||
editAddress,
|
||||
getAddressDetail
|
||||
} from '@/api/user.js';
|
||||
import { wgsToGcj } from "@/utils/wgs.js";
|
||||
import {
|
||||
getCityV2,
|
||||
getCityList
|
||||
@ -284,8 +285,9 @@
|
||||
});
|
||||
if (uni.getStorageSync('RejectTarget')) return
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
res = wgsToGcj(res);
|
||||
let latitude, longitude;
|
||||
latitude = res.latitude.toString();
|
||||
longitude = res.longitude.toString();
|
||||
|
147
utils/WSCoordinate.js
Normal file
147
utils/WSCoordinate.js
Normal file
@ -0,0 +1,147 @@
|
||||
/**
|
||||
* 判断经纬度是否超出中国境内
|
||||
*/
|
||||
function isLocationOutOfChina(latitude, longitude) {
|
||||
if (longitude < 72.004 || longitude > 137.8347 || latitude < 0.8293 || latitude > 55.8271)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将WGS-84(国际标准)转为GCJ-02(火星坐标):
|
||||
*/
|
||||
function transformFromWGSToGCJ(latitude, longitude) {
|
||||
var lat = "";
|
||||
var lon = "";
|
||||
var ee = 0.00669342162296594323;
|
||||
var a = 6378245.0;
|
||||
var pi = 3.14159265358979324;
|
||||
|
||||
if (isLocationOutOfChina(latitude, longitude)) {
|
||||
lat = latitude;
|
||||
lon = longitude;
|
||||
}
|
||||
else {
|
||||
var adjustLat = transformLatWithXY(longitude - 105.0, latitude - 35.0);
|
||||
var adjustLon = transformLonWithXY(longitude - 105.0, latitude - 35.0);
|
||||
var radLat = latitude / 180.0 * pi;
|
||||
var magic = Math.sin(radLat);
|
||||
magic = 1 - ee * magic * magic;
|
||||
var sqrtMagic = Math.sqrt(magic);
|
||||
adjustLat = (adjustLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
|
||||
adjustLon = (adjustLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
|
||||
latitude = latitude + adjustLat;
|
||||
longitude = longitude + adjustLon;
|
||||
}
|
||||
return { latitude: latitude, longitude: longitude };
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 将GCJ-02(火星坐标)转为百度坐标:
|
||||
*/
|
||||
function transformFromGCJToBaidu(latitude, longitude) {
|
||||
var pi = 3.14159265358979324 * 3000.0 / 180.0;
|
||||
|
||||
var z = Math.sqrt(longitude * longitude + latitude * latitude) + 0.00002 * Math.sin(latitude * pi);
|
||||
var theta = Math.atan2(latitude, longitude) + 0.000003 * Math.cos(longitude * pi);
|
||||
var a_latitude = (z * Math.sin(theta) + 0.006);
|
||||
var a_longitude = (z * Math.cos(theta) + 0.0065);
|
||||
|
||||
return { latitude: a_latitude, longitude: a_longitude };
|
||||
}
|
||||
|
||||
/**
|
||||
* 将百度坐标转为GCJ-02(火星坐标):
|
||||
*/
|
||||
function transformFromBaiduToGCJ(latitude, longitude) {
|
||||
var xPi = 3.14159265358979323846264338327950288 * 3000.0 / 180.0;
|
||||
|
||||
var x = longitude - 0.0065;
|
||||
var y = latitude - 0.006;
|
||||
var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * xPi);
|
||||
var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * xPi);
|
||||
var a_latitude = z * Math.sin(theta);
|
||||
var a_longitude = z * Math.cos(theta);
|
||||
|
||||
return { latitude: a_latitude, longitude: a_longitude };
|
||||
}
|
||||
|
||||
/**
|
||||
* 将GCJ-02(火星坐标)转为WGS-84:
|
||||
*/
|
||||
function transformFromGCJToWGS(latitude, longitude) {
|
||||
var threshold = 0.00001;
|
||||
|
||||
// The boundary
|
||||
var minLat = latitude - 0.5;
|
||||
var maxLat = latitude + 0.5;
|
||||
var minLng = longitude - 0.5;
|
||||
var maxLng = longitude + 0.5;
|
||||
|
||||
var delta = 1;
|
||||
var maxIteration = 30;
|
||||
|
||||
while (true) {
|
||||
var leftBottom = transformFromWGSToGCJ(minLat, minLng);
|
||||
var rightBottom = transformFromWGSToGCJ(minLat, maxLng);
|
||||
var leftUp = transformFromWGSToGCJ(maxLat, minLng);
|
||||
var midPoint = transformFromWGSToGCJ((minLat + maxLat) / 2, (minLng + maxLng) / 2);
|
||||
delta = Math.abs(midPoint.latitude - latitude) + Math.abs(midPoint.longitude - longitude);
|
||||
|
||||
if (maxIteration-- <= 0 || delta <= threshold) {
|
||||
return { latitude: (minLat + maxLat) / 2, longitude: (minLng + maxLng) / 2 };
|
||||
}
|
||||
|
||||
if (isContains({ latitude: latitude, longitude: longitude }, leftBottom, midPoint)) {
|
||||
maxLat = (minLat + maxLat) / 2;
|
||||
maxLng = (minLng + maxLng) / 2;
|
||||
}
|
||||
else if (isContains({ latitude: latitude, longitude: longitude }, rightBottom, midPoint)) {
|
||||
maxLat = (minLat + maxLat) / 2;
|
||||
minLng = (minLng + maxLng) / 2;
|
||||
}
|
||||
else if (isContains({ latitude: latitude, longitude: longitude }, leftUp, midPoint)) {
|
||||
minLat = (minLat + maxLat) / 2;
|
||||
maxLng = (minLng + maxLng) / 2;
|
||||
}
|
||||
else {
|
||||
minLat = (minLat + maxLat) / 2;
|
||||
minLng = (minLng + maxLng) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function isContains(point, p1, p2) {
|
||||
return (point.latitude >= Math.min(p1.latitude, p2.latitude) && point.latitude <= Math.max(p1.latitude, p2.latitude)) && (point.longitude >= Math.min(p1.longitude, p2.longitude) && point.longitude <= Math.max(p1.longitude, p2.longitude));
|
||||
}
|
||||
|
||||
function transformLatWithXY(x, y) {
|
||||
var pi = 3.14159265358979324;
|
||||
var lat = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
|
||||
lat += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
|
||||
lat += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;
|
||||
lat += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;
|
||||
return lat;
|
||||
}
|
||||
|
||||
function transformLonWithXY(x, y) {
|
||||
var pi = 3.14159265358979324;
|
||||
var lon = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
|
||||
lon += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
|
||||
lon += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;
|
||||
lon += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0 * pi)) * 2.0 / 3.0;
|
||||
return lon;
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
isLocationOutOfChina: isLocationOutOfChina,
|
||||
transformFromWGSToGCJ: transformFromWGSToGCJ,
|
||||
transformFromGCJToBaidu: transformFromGCJToBaidu,
|
||||
transformFromBaiduToGCJ: transformFromBaiduToGCJ,
|
||||
transformFromGCJToWGS: transformFromGCJToWGS
|
||||
}
|
@ -5,7 +5,7 @@ export const test = () => {
|
||||
export const uniMPgetLocation = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
type: 'wgs84',
|
||||
geocode: true,
|
||||
isHighAccuracy: true,
|
||||
// altitude: true,
|
||||
|
14
utils/wgs.js
Normal file
14
utils/wgs.js
Normal file
@ -0,0 +1,14 @@
|
||||
const util = require('./WSCoordinate.js')
|
||||
|
||||
export const wgsToGcj = (data)=>{
|
||||
try{
|
||||
let d = data;
|
||||
//将WGS-84(国际标准)转为GCJ-02(火星坐标)
|
||||
let e = util.transformFromWGSToGCJ(data.latitude, data.longitude);
|
||||
d.latitude = e.latitude;
|
||||
d.longitude = e.longitude;
|
||||
return d;
|
||||
}catch(e){
|
||||
return data;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user