|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
let app = getApp()
|
|
|
|
|
// 引入SDK核心类,js文件根据自己业务,位置可自行放置
|
|
|
|
|
// import p from "wl-pinyin";
|
|
|
|
|
var QQMapWX = require('../../utils/qqmap-wx-jssdk.min');
|
|
|
|
|
var qqmapsdk;
|
|
|
|
|
// 映入面数据
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -12,19 +12,19 @@ Page({
|
|
|
|
|
cityName:'',
|
|
|
|
|
show:false,
|
|
|
|
|
columns:[
|
|
|
|
|
{id:1045,name:'南京市'},
|
|
|
|
|
{id:1061,name:'无锡市'},
|
|
|
|
|
{id:1071,name:'徐州市'},
|
|
|
|
|
{id:1084,name:'常州市'},
|
|
|
|
|
{id:1093,name:'苏州市'},
|
|
|
|
|
{id:1108,name:'南通市'},
|
|
|
|
|
{id:1119,name:'连云港'},
|
|
|
|
|
{id:1130,name:'淮安市'},
|
|
|
|
|
{id:1141,name:'盐城市'},
|
|
|
|
|
{id:1152,name:'扬州市'},
|
|
|
|
|
{id:1161,name:'镇江市'},
|
|
|
|
|
{id:1169,name:'泰州市'},
|
|
|
|
|
{id:1177,name:'宿迁市'},
|
|
|
|
|
{id:1045,name:'南京市',pinyin:'nanjing'},
|
|
|
|
|
{id:1061,name:'无锡市',pinyin:'wuxi'},
|
|
|
|
|
{id:1071,name:'徐州市',pinyin:'xuzhou'},
|
|
|
|
|
{id:1084,name:'常州市',pinyin:'changzhou'},
|
|
|
|
|
{id:1093,name:'苏州市',pinyin:'suzhou'},
|
|
|
|
|
{id:1108,name:'南通市',pinyin:'nantong'},
|
|
|
|
|
{id:1119,name:'连云港',pinyin:'lianyungang'},
|
|
|
|
|
{id:1130,name:'淮安市',pinyin:'huaian'},
|
|
|
|
|
{id:1141,name:'盐城市',pinyin:'yancheng'},
|
|
|
|
|
{id:1152,name:'扬州市',pinyin:'yangzhou'},
|
|
|
|
|
{id:1161,name:'镇江市',pinyin:"zhenjiang"},
|
|
|
|
|
{id:1169,name:'泰州市',pinyin:"taizhou"},
|
|
|
|
|
{id:1177,name:'宿迁市',pinyin:'suqian'},
|
|
|
|
|
],
|
|
|
|
|
code:0,
|
|
|
|
|
latitude: 31.942406,
|
|
|
|
@ -402,8 +402,11 @@ Page({
|
|
|
|
|
qqmapsdk = new QQMapWX({
|
|
|
|
|
key: 'CECBZ-55LCW-TSYR7-O4UGV-75DE7-2JBQH',
|
|
|
|
|
});
|
|
|
|
|
// 请求面数据
|
|
|
|
|
this.getMian()
|
|
|
|
|
|
|
|
|
|
this.showGroundOverlay()
|
|
|
|
|
|
|
|
|
|
//初次进入获取定位
|
|
|
|
|
this.getUserLocation()
|
|
|
|
|
},
|
|
|
|
|
//打开选择市区
|
|
|
|
|
cityClick(){
|
|
|
|
@ -420,18 +423,23 @@ Page({
|
|
|
|
|
//确定
|
|
|
|
|
onConfirm(e){
|
|
|
|
|
let selData = e.detail
|
|
|
|
|
console.log(selData)
|
|
|
|
|
this.setData({
|
|
|
|
|
show:false,
|
|
|
|
|
code:selData.index,
|
|
|
|
|
cityName:selData.value
|
|
|
|
|
cityName:selData.value,
|
|
|
|
|
polyline: [],
|
|
|
|
|
polygons: [],
|
|
|
|
|
polyline2: [],
|
|
|
|
|
polygons2: [],
|
|
|
|
|
})
|
|
|
|
|
//获取地区天气
|
|
|
|
|
this.getWeatherData()
|
|
|
|
|
//获取地区坐标
|
|
|
|
|
this.getCityLoaction()
|
|
|
|
|
this.getMian(this.data.columns[selData.index].pinyin)
|
|
|
|
|
},
|
|
|
|
|
getCityLoaction(){
|
|
|
|
|
console.log(this.data.cityName)
|
|
|
|
|
qqmapsdk.geocoder({
|
|
|
|
|
address:this.data.cityName,
|
|
|
|
|
sig: "BmvXO4wJDbVYKa7yrzuIY2wPuXKaxetj",
|
|
|
|
@ -447,15 +455,7 @@ Page({
|
|
|
|
|
//地图定位
|
|
|
|
|
getLcation() {
|
|
|
|
|
var mapCtx = wx.createMapContext('map')
|
|
|
|
|
wx.getLocation({
|
|
|
|
|
type: 'gcj02',
|
|
|
|
|
success: (res) => {
|
|
|
|
|
mapCtx.moveToLocation({
|
|
|
|
|
longitude: res.longitude,
|
|
|
|
|
latitude: res.latitude,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
mapCtx.moveToLocation()
|
|
|
|
|
},
|
|
|
|
|
//获取天气
|
|
|
|
|
getWeatherData(e) {
|
|
|
|
@ -480,16 +480,17 @@ Page({
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
//请求面数据
|
|
|
|
|
getMian() {
|
|
|
|
|
app.fetch('9017/jsonData/nanjing.json',{},false,'GET').then(res=>{
|
|
|
|
|
// console.log(res)
|
|
|
|
|
let list = res.features[0].geometry.coordinates[0][0]
|
|
|
|
|
getMian(pinyin) {
|
|
|
|
|
console.log(pinyin)
|
|
|
|
|
app.fetch(`9017/jsonData/${pinyin}.json`,{},false,'GET').then(res=>{
|
|
|
|
|
|
|
|
|
|
let list = res.features[0].geometry.coordinates[0]
|
|
|
|
|
let mianList = [{
|
|
|
|
|
points: [],
|
|
|
|
|
fillColor: "#A2D1B4", //前六位数字表示多边形背景颜色,后两位表示透明度,90是不透明多90%,反过来透明度10%
|
|
|
|
|
strokeColor: "#B7E7C7",
|
|
|
|
|
strokeWidth: 2,
|
|
|
|
|
zIndex: 2
|
|
|
|
|
zIndex: 50
|
|
|
|
|
}]
|
|
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
|
|
mianList[0].points.push({
|
|
|
|
@ -497,12 +498,13 @@ Page({
|
|
|
|
|
latitude: list[i][1],
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
this.getMianShadow(mianList)
|
|
|
|
|
|
|
|
|
|
this.getMianShadow(mianList,pinyin)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
//获取面阴影
|
|
|
|
|
getMianShadow(mianList) {
|
|
|
|
|
app.fetch('9017/jsonData/nanjing-shaw.json',{},false,'GET').then(res=>{
|
|
|
|
|
getMianShadow(mianList,pinyin) {
|
|
|
|
|
app.fetch(`9017/jsonData/${pinyin}-shaw.json`,{},false,'GET').then(res=>{
|
|
|
|
|
let lists = res.features[0].geometry.coordinates
|
|
|
|
|
for (let j = 0; j < lists.length; j++) {
|
|
|
|
|
var shadow = {
|
|
|
|
@ -522,15 +524,15 @@ Page({
|
|
|
|
|
mianList.push(shadow)
|
|
|
|
|
}
|
|
|
|
|
//河流
|
|
|
|
|
this.getRiver(mianList)
|
|
|
|
|
//高速公路
|
|
|
|
|
this.getWaydata()
|
|
|
|
|
this.getRiver(mianList,pinyin)
|
|
|
|
|
// //高速公路
|
|
|
|
|
this.getWaydata(pinyin)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//河流
|
|
|
|
|
getRiver(mianList) {
|
|
|
|
|
app.fetch('9017/jsonData/nanjing-river.json',{},false,'GET').then(res=>{
|
|
|
|
|
getRiver(mianList,pinyin) {
|
|
|
|
|
app.fetch(`9017/jsonData/${pinyin}-river.json`,{},false,'GET').then(res=>{
|
|
|
|
|
let list = res.features
|
|
|
|
|
list.forEach(item => {
|
|
|
|
|
var rr = {
|
|
|
|
@ -538,7 +540,7 @@ Page({
|
|
|
|
|
fillColor: "#5ED2E0", //前六位数字表示多边形背景颜色,后两位表示透明度,90是不透明多90%,反过来透明度10%
|
|
|
|
|
strokeColor: 'none',
|
|
|
|
|
strokeWidth: 0,
|
|
|
|
|
zIndex: 2,
|
|
|
|
|
zIndex: 3,
|
|
|
|
|
}
|
|
|
|
|
item.geometry.coordinates.forEach(data => {
|
|
|
|
|
data.forEach(river => {
|
|
|
|
@ -559,8 +561,8 @@ Page({
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
//高速公路
|
|
|
|
|
getWaydata() {
|
|
|
|
|
app.fetch('9017/jsonData/nanjing-way.json',{},false,'GET').then(res=>{
|
|
|
|
|
getWaydata(pinyin) {
|
|
|
|
|
app.fetch(`9017/jsonData/${pinyin}-way.json`,{},false,'GET').then(res=>{
|
|
|
|
|
let list = res.features
|
|
|
|
|
let lineList = []
|
|
|
|
|
list.forEach((item, index) => {
|
|
|
|
@ -632,29 +634,39 @@ Page({
|
|
|
|
|
//视野发生变化时触发,
|
|
|
|
|
handleRegionChange(ev) {
|
|
|
|
|
var mapCtx = wx.createMapContext('map')
|
|
|
|
|
mapCtx.removeGroundOverlay({
|
|
|
|
|
id: 1
|
|
|
|
|
})
|
|
|
|
|
this.setData({
|
|
|
|
|
style: 2,
|
|
|
|
|
})
|
|
|
|
|
// 第一层级平移
|
|
|
|
|
if (this.data.nowScale == 8.5) {
|
|
|
|
|
mapCtx.removeGroundOverlay({
|
|
|
|
|
id: 1
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ev.detail.type === 'end') {
|
|
|
|
|
var nowScale = ev.detail.scale
|
|
|
|
|
// console.log(nowScale)
|
|
|
|
|
if (nowScale != this.data.nowScale) {
|
|
|
|
|
if (nowScale > 10 && this.data.nowScale <= 10) {
|
|
|
|
|
if (nowScale > 9.5 && this.data.nowScale <= 9.5) {
|
|
|
|
|
this.setData({
|
|
|
|
|
polyline: [],
|
|
|
|
|
polygons: [],
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if (nowScale <= 10 && this.data.nowScale > 10) {
|
|
|
|
|
if (nowScale <= 9.5 && this.data.nowScale > 9.5) {
|
|
|
|
|
this.setData({
|
|
|
|
|
polyline: this.data.polyline2,
|
|
|
|
|
polygons: this.data.polygons2,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if (nowScale != 8.5 && this.data.nowScale == 8.5) {
|
|
|
|
|
mapCtx.removeGroundOverlay({
|
|
|
|
|
id: 1
|
|
|
|
|
})
|
|
|
|
|
this.setData({
|
|
|
|
|
style: 2,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
|
nowScale: nowScale
|
|
|
|
|
})
|
|
|
|
@ -676,9 +688,9 @@ Page({
|
|
|
|
|
// this.setData({
|
|
|
|
|
// style: 1
|
|
|
|
|
// })
|
|
|
|
|
console.log('页面显示')
|
|
|
|
|
//初次进入获取定位
|
|
|
|
|
this.getUserLocation()
|
|
|
|
|
// console.log('页面显示')
|
|
|
|
|
// //初次进入获取定位
|
|
|
|
|
// this.getUserLocation()
|
|
|
|
|
},
|
|
|
|
|
getUserLocation(){
|
|
|
|
|
let _this = this
|
|
|
|
@ -758,8 +770,13 @@ Page({
|
|
|
|
|
code:index,
|
|
|
|
|
latitude: res.result.location.lat,
|
|
|
|
|
longitude: res.result.location.lng,
|
|
|
|
|
style: 1,
|
|
|
|
|
scale: 8.5,
|
|
|
|
|
})
|
|
|
|
|
let pinyin = _this.data.columns[index].pinyin
|
|
|
|
|
_this.getWeatherData()
|
|
|
|
|
// 请求面数据
|
|
|
|
|
_this.getMian(pinyin)
|
|
|
|
|
},
|
|
|
|
|
fail: function (error) {
|
|
|
|
|
console.log('腾讯api调取失败:',error);
|
|
|
|
@ -772,11 +789,6 @@ Page({
|
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
|
*/
|
|
|
|
|
onHide() {
|
|
|
|
|
this.setData({
|
|
|
|
|
latitude: 31.942406,
|
|
|
|
|
longitude: 118.836155,
|
|
|
|
|
scale: 8.5,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|