Merge branch 'liujun-2023-12-14-地图插件更新' into zy-1214-重点工程播放视频
commit
51619b6c86
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,59 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>地图</title>
|
||||
</head>
|
||||
<script src="http://api.tianditu.gov.cn/api?v=4.0&tk=e8a16137fd226a62a23cc7ba5c9c78ce" type="text/javascript">
|
||||
</script>
|
||||
<script src="./js/uni.webview.1.5.4.js"></script>
|
||||
<body onLoad="onLoad()">
|
||||
<div id="mapDiv" style="position:absolute;width:100vw; height:100vh"></div>
|
||||
</body>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var map;
|
||||
var zoom = 14;
|
||||
|
||||
function getUrlParam(name) {
|
||||
const reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
|
||||
const r = window.location.search.substr(1).match(reg);
|
||||
if (r != null) return decodeURI(r[2]);
|
||||
return "";
|
||||
}
|
||||
|
||||
function onLoad() {
|
||||
var imageURL = "http://t0.tianditu.gov.cn/img_w/wmts?" +
|
||||
"SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
|
||||
"&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=e8a16137fd226a62a23cc7ba5c9c78ce";
|
||||
lay = new T.TileLayer(imageURL, {minZoom: 1, maxZoom: 18});
|
||||
var config = {layers: [lay]};
|
||||
map = new T.Map("mapDiv", config);
|
||||
map.centerAndZoom(new T.LngLat(getUrlParam('longitude'), getUrlParam('latitude')), zoom);
|
||||
map.enableScrollWheelZoom();
|
||||
addMapClick()
|
||||
}
|
||||
function addMapClick() {
|
||||
map.addEventListener("click", MapClick);
|
||||
}
|
||||
|
||||
function MapClick(event) {
|
||||
var marker = new T.Marker(new T.LngLat(event.lnglat.getLng(), event.lnglat.getLat()));
|
||||
map.clearOverLays();
|
||||
map.addOverLay(marker);
|
||||
console.log(event.lnglat.getLng(), event.lnglat.getLat());
|
||||
uni.postMessage({
|
||||
data: {
|
||||
"longitue": event.lnglat.getLng(),
|
||||
"latitude": event.lnglat.getLat(),
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</html>
|
|
@ -469,6 +469,12 @@
|
|||
"navigationBarTitleText": "地图"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/map/mapPro",
|
||||
"style" : {
|
||||
"navigationBarTitleText": "地图"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/information/index/index",
|
||||
"style": {
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
<template>
|
||||
<view>
|
||||
<cu-custom bgColor="bg-gradual-blueness" :isBack="true">
|
||||
<block slot="backText">返回</block>
|
||||
<block slot="content">位置定位</block>
|
||||
</cu-custom>
|
||||
<web-view id="webview" :src="url" @message="messageChange"></web-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
export default {
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
url: '',
|
||||
longitude: '',
|
||||
latitude: ''
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
this.longitude = 119.67751
|
||||
this.latitude = 39.92596
|
||||
this.init();
|
||||
const eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
|
||||
// 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
|
||||
eventChannel.on('acceptDataFromOpenerPage', function (data) {
|
||||
console.log(data)
|
||||
})
|
||||
},
|
||||
|
||||
onBackPress(options) {
|
||||
return false;
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
},
|
||||
|
||||
onShow() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
goBack() {
|
||||
uni.navigateBack()
|
||||
},
|
||||
saveData() {
|
||||
|
||||
},
|
||||
init() {
|
||||
this.url = ('/hybrid/html/newMap.html?longitude='+this.longitude+'&latitude='+this.latitude+ 't=' + new Date().getTime());
|
||||
console.log(this.url);
|
||||
},
|
||||
messageChange(e) {
|
||||
console.log("messageChange");
|
||||
console.log(e);
|
||||
uni.setStorageSync("info", e.detail.data[0]);
|
||||
const eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
|
||||
console.log(eventChannel)
|
||||
eventChannel.emit('acceptDataFromOpenedPage', {data: e.detail.data[0]});
|
||||
uni.navigateBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
|
||||
page,
|
||||
uni-page-body,
|
||||
.container {
|
||||
background: rgba(245, 245, 245, 1);
|
||||
min-height: calc(100%);
|
||||
}
|
||||
|
||||
</style>
|
|
@ -903,7 +903,7 @@ export default {
|
|||
showMapModal() {
|
||||
let _this = this
|
||||
uni.navigateTo({
|
||||
url: '/pages/map/map',
|
||||
url: '/pages/map/mapPro',
|
||||
events: {
|
||||
acceptDataFromOpenedPage: function (e) {
|
||||
_this.hiddenForm.LONGITUDE = e.data.longitue;
|
||||
|
|
Loading…
Reference in New Issue