|
|
|
@ -9,11 +9,24 @@ Page({
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
cityName:'南京',
|
|
|
|
|
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:'宿迁市'},
|
|
|
|
|
],
|
|
|
|
|
code:0,
|
|
|
|
|
latitude: 31.942406,
|
|
|
|
|
longitude: 118.836155,
|
|
|
|
|
temp: 0,
|
|
|
|
@ -388,13 +401,11 @@ Page({
|
|
|
|
|
// 实例化API核心类
|
|
|
|
|
qqmapsdk = new QQMapWX({
|
|
|
|
|
key: 'CECBZ-55LCW-TSYR7-O4UGV-75DE7-2JBQH',
|
|
|
|
|
sig: "BmvXO4wJDbVYKa7yrzuIY2wPuXKaxetj"
|
|
|
|
|
});
|
|
|
|
|
// this.getWeatherData()
|
|
|
|
|
// this.showGroundOverlay()
|
|
|
|
|
// this.getMian()
|
|
|
|
|
// 请求面数据
|
|
|
|
|
this.getMian()
|
|
|
|
|
},
|
|
|
|
|
//选择市区
|
|
|
|
|
//打开选择市区
|
|
|
|
|
cityClick(){
|
|
|
|
|
this.setData({
|
|
|
|
|
show:true,
|
|
|
|
@ -408,10 +419,14 @@ Page({
|
|
|
|
|
},
|
|
|
|
|
//确定
|
|
|
|
|
onConfirm(e){
|
|
|
|
|
let selData = e.detail
|
|
|
|
|
this.setData({
|
|
|
|
|
show:false,
|
|
|
|
|
cityName:e.detail.value
|
|
|
|
|
code:selData.index,
|
|
|
|
|
cityName:selData.value
|
|
|
|
|
})
|
|
|
|
|
//获取地区天气
|
|
|
|
|
this.getWeatherData()
|
|
|
|
|
},
|
|
|
|
|
//地图定位
|
|
|
|
|
getLcation() {
|
|
|
|
@ -427,7 +442,7 @@ Page({
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
//获取天气
|
|
|
|
|
getWeatherData() {
|
|
|
|
|
getWeatherData(e) {
|
|
|
|
|
var now = new Date();
|
|
|
|
|
var year = now.getFullYear();
|
|
|
|
|
var month = now.getMonth() + 1;
|
|
|
|
@ -435,31 +450,24 @@ Page({
|
|
|
|
|
month = month >= 10 ? month : '0' + month
|
|
|
|
|
date = date >= 10 ? date : '0' + date
|
|
|
|
|
let nowTimer = year + '-' + month + '-' + date
|
|
|
|
|
wx.request({
|
|
|
|
|
url: 'https://www.jichuanglanhai.com:9018/Luying/getweatherdata/getdata',
|
|
|
|
|
method: 'GET',
|
|
|
|
|
data: {
|
|
|
|
|
Cityid: 1045,
|
|
|
|
|
date: nowTimer
|
|
|
|
|
},
|
|
|
|
|
success: (res) => {
|
|
|
|
|
this.setData({
|
|
|
|
|
temp: res.data.data.temp,
|
|
|
|
|
tempCode: `http://www.jichuanglanhai.com/demo/yingdi-file/W${res.data.data.icon}.png`
|
|
|
|
|
let params = {
|
|
|
|
|
Cityid:this.data.columns[this.data.code].id,
|
|
|
|
|
date: nowTimer
|
|
|
|
|
}
|
|
|
|
|
app.fetch('9018/Luying/getweatherdata/getdata',params,false,'GET').then(res=>{
|
|
|
|
|
if(res.code == 200){
|
|
|
|
|
this.setData({
|
|
|
|
|
temp: res.data.temp,
|
|
|
|
|
tempCode: `http://www.jichuanglanhai.com/demo/yingdi-file/W${res.data.icon}.png`
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
//请求面数据
|
|
|
|
|
getMian() {
|
|
|
|
|
//请求面数据
|
|
|
|
|
wx.request({
|
|
|
|
|
url: 'https://www.jichuanglanhai.com:9017/jsonData/nanjing.json',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
|
},
|
|
|
|
|
success: (res) => {
|
|
|
|
|
let list = res.data.features[0].geometry.coordinates[0][0]
|
|
|
|
|
app.fetch('9017/jsonData/nanjing.json',{},false,'GET').then(res=>{
|
|
|
|
|
// console.log(res)
|
|
|
|
|
let list = res.features[0].geometry.coordinates[0][0]
|
|
|
|
|
let mianList = [{
|
|
|
|
|
points: [],
|
|
|
|
|
fillColor: "#A2D1B4", //前六位数字表示多边形背景颜色,后两位表示透明度,90是不透明多90%,反过来透明度10%
|
|
|
|
@ -468,117 +476,99 @@ Page({
|
|
|
|
|
zIndex: 2
|
|
|
|
|
}]
|
|
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
|
|
mianList[0].points.push({
|
|
|
|
|
longitude: list[i][0],
|
|
|
|
|
latitude: list[i][1],
|
|
|
|
|
})
|
|
|
|
|
mianList[0].points.push({
|
|
|
|
|
longitude: list[i][0],
|
|
|
|
|
latitude: list[i][1],
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
this.getMianShadow(mianList)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
//获取面阴影
|
|
|
|
|
getMianShadow(mianList) {
|
|
|
|
|
wx.request({
|
|
|
|
|
url: 'https://www.jichuanglanhai.com:9017/jsonData/nanjing-shaw.json',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
|
},
|
|
|
|
|
success: (res) => {
|
|
|
|
|
let lists = res.data.features[0].geometry.coordinates
|
|
|
|
|
for (let j = 0; j < lists.length; j++) {
|
|
|
|
|
var shadow = {
|
|
|
|
|
points: [],
|
|
|
|
|
fillColor: "#437353", //前六位数字表示多边形背景颜色,后两位表示透明度,90是不透明多90%,反过来透明度10%
|
|
|
|
|
strokeColor: 'none',
|
|
|
|
|
strokeWidth: 0,
|
|
|
|
|
zIndex: 2
|
|
|
|
|
}
|
|
|
|
|
var list = lists[j][0]
|
|
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
|
|
shadow.points.push({
|
|
|
|
|
longitude: list[i][0],
|
|
|
|
|
latitude: list[i][1],
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
mianList.push(shadow)
|
|
|
|
|
app.fetch('9017/jsonData/nanjing-shaw.json',{},false,'GET').then(res=>{
|
|
|
|
|
let lists = res.features[0].geometry.coordinates
|
|
|
|
|
for (let j = 0; j < lists.length; j++) {
|
|
|
|
|
var shadow = {
|
|
|
|
|
points: [],
|
|
|
|
|
fillColor: "#437353", //前六位数字表示多边形背景颜色,后两位表示透明度,90是不透明多90%,反过来透明度10%
|
|
|
|
|
strokeColor: 'none',
|
|
|
|
|
strokeWidth: 0,
|
|
|
|
|
zIndex: 2
|
|
|
|
|
}
|
|
|
|
|
var list = lists[j][0]
|
|
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
|
|
shadow.points.push({
|
|
|
|
|
longitude: list[i][0],
|
|
|
|
|
latitude: list[i][1],
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
mianList.push(shadow)
|
|
|
|
|
}
|
|
|
|
|
//河流
|
|
|
|
|
this.getRiver(mianList)
|
|
|
|
|
//高速公路
|
|
|
|
|
this.getWaydata()
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//河流
|
|
|
|
|
getRiver(mianList) {
|
|
|
|
|
wx.request({
|
|
|
|
|
url: 'https://www.jichuanglanhai.com:9017/jsonData/nanjing-river.json',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
|
},
|
|
|
|
|
success: (res) => {
|
|
|
|
|
let list = res.data.features
|
|
|
|
|
list.forEach(item => {
|
|
|
|
|
var rr = {
|
|
|
|
|
points: [],
|
|
|
|
|
fillColor: "#5ED2E0", //前六位数字表示多边形背景颜色,后两位表示透明度,90是不透明多90%,反过来透明度10%
|
|
|
|
|
strokeColor: 'none',
|
|
|
|
|
strokeWidth: 0,
|
|
|
|
|
zIndex: 2,
|
|
|
|
|
}
|
|
|
|
|
item.geometry.coordinates.forEach(data => {
|
|
|
|
|
data.forEach(river => {
|
|
|
|
|
river.forEach(it => {
|
|
|
|
|
rr.points.push({
|
|
|
|
|
longitude: it[0],
|
|
|
|
|
latitude: it[1],
|
|
|
|
|
})
|
|
|
|
|
app.fetch('9017/jsonData/nanjing-river.json',{},false,'GET').then(res=>{
|
|
|
|
|
let list = res.features
|
|
|
|
|
list.forEach(item => {
|
|
|
|
|
var rr = {
|
|
|
|
|
points: [],
|
|
|
|
|
fillColor: "#5ED2E0", //前六位数字表示多边形背景颜色,后两位表示透明度,90是不透明多90%,反过来透明度10%
|
|
|
|
|
strokeColor: 'none',
|
|
|
|
|
strokeWidth: 0,
|
|
|
|
|
zIndex: 2,
|
|
|
|
|
}
|
|
|
|
|
item.geometry.coordinates.forEach(data => {
|
|
|
|
|
data.forEach(river => {
|
|
|
|
|
river.forEach(it => {
|
|
|
|
|
rr.points.push({
|
|
|
|
|
longitude: it[0],
|
|
|
|
|
latitude: it[1],
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
mianList.push(rr)
|
|
|
|
|
})
|
|
|
|
|
this.setData({
|
|
|
|
|
polygons: mianList,
|
|
|
|
|
polygons2: mianList
|
|
|
|
|
})
|
|
|
|
|
// console.log(this.data.polygons,'数据')
|
|
|
|
|
},
|
|
|
|
|
mianList.push(rr)
|
|
|
|
|
})
|
|
|
|
|
this.setData({
|
|
|
|
|
polygons: mianList,
|
|
|
|
|
polygons2: mianList
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
//高速公路
|
|
|
|
|
getWaydata() {
|
|
|
|
|
wx.request({
|
|
|
|
|
url: 'https://www.jichuanglanhai.com:9017/jsonData/nanjing-way.json',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
|
},
|
|
|
|
|
success: (res) => {
|
|
|
|
|
let list = res.data.features
|
|
|
|
|
let lineList = []
|
|
|
|
|
list.forEach((item, index) => {
|
|
|
|
|
lineList[index] = {
|
|
|
|
|
points: [],
|
|
|
|
|
color: '#C6E9CD',
|
|
|
|
|
width: 3
|
|
|
|
|
}
|
|
|
|
|
item.geometry.coordinates.forEach(line => {
|
|
|
|
|
line.forEach(datas => {
|
|
|
|
|
lineList[index].points.push({
|
|
|
|
|
longitude: datas[0],
|
|
|
|
|
latitude: datas[1]
|
|
|
|
|
})
|
|
|
|
|
app.fetch('9017/jsonData/nanjing-way.json',{},false,'GET').then(res=>{
|
|
|
|
|
let list = res.features
|
|
|
|
|
let lineList = []
|
|
|
|
|
list.forEach((item, index) => {
|
|
|
|
|
lineList[index] = {
|
|
|
|
|
points: [],
|
|
|
|
|
color: '#C6E9CD',
|
|
|
|
|
width: 3
|
|
|
|
|
}
|
|
|
|
|
item.geometry.coordinates.forEach(line => {
|
|
|
|
|
line.forEach(datas => {
|
|
|
|
|
lineList[index].points.push({
|
|
|
|
|
longitude: datas[0],
|
|
|
|
|
latitude: datas[1]
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
this.setData({
|
|
|
|
|
polyline: lineList,
|
|
|
|
|
polyline2: lineList
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
this.setData({
|
|
|
|
|
polyline: lineList,
|
|
|
|
|
polyline2: lineList
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//单击地图的marker
|
|
|
|
|
clickMapMarker(e) {
|
|
|
|
@ -670,7 +660,7 @@ Page({
|
|
|
|
|
// this.setData({
|
|
|
|
|
// style: 1
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
console.log('页面显示')
|
|
|
|
|
//初次进入获取定位
|
|
|
|
|
this.getUserLocation()
|
|
|
|
|
},
|
|
|
|
@ -717,11 +707,11 @@ Page({
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}else if(res.authSetting['scope.userLocation'] == undefined) {
|
|
|
|
|
//用户首次进入页面
|
|
|
|
|
_this.geo();
|
|
|
|
|
console.log('初次进入')
|
|
|
|
|
//用户首次进入页面
|
|
|
|
|
_this.geo();
|
|
|
|
|
// console.log('初次进入')
|
|
|
|
|
}else{
|
|
|
|
|
console.log('授权成功')
|
|
|
|
|
// console.log('授权成功')
|
|
|
|
|
//已授权
|
|
|
|
|
_this.geo();
|
|
|
|
|
}
|
|
|
|
@ -733,18 +723,28 @@ Page({
|
|
|
|
|
geo: function () {
|
|
|
|
|
var _this = this;
|
|
|
|
|
wx.getLocation({
|
|
|
|
|
type: 'wgs84',
|
|
|
|
|
type: 'gcj02',
|
|
|
|
|
isHighAccuracy: true,//开启高精度定位
|
|
|
|
|
success: function (res) {
|
|
|
|
|
let {latitude,longitude} = res
|
|
|
|
|
// 调用腾讯地图api获取当前位置
|
|
|
|
|
qqmapsdk.reverseGeocoder({
|
|
|
|
|
sig: "BmvXO4wJDbVYKa7yrzuIY2wPuXKaxetj",
|
|
|
|
|
location: {
|
|
|
|
|
latitude: latitude,
|
|
|
|
|
longitude: longitude
|
|
|
|
|
},
|
|
|
|
|
success: function (res) {
|
|
|
|
|
console.log(res.result)
|
|
|
|
|
// console.log(res.result)
|
|
|
|
|
//获取城市id
|
|
|
|
|
let index =_this.data.columns.findIndex(item=>item.name == res.result.address_component.city)
|
|
|
|
|
_this.setData({
|
|
|
|
|
cityName:res.result.address_component.city,
|
|
|
|
|
code:index,
|
|
|
|
|
// latitude: res.result.location.lat,
|
|
|
|
|
// longitude: res.result.location.lng,
|
|
|
|
|
})
|
|
|
|
|
_this.getWeatherData()
|
|
|
|
|
},
|
|
|
|
|
fail: function (error) {
|
|
|
|
|
console.log('腾讯api调取失败:',error);
|
|
|
|
|