var app =
getApp
(
)
;
?
Page
{
??
data
:
{
????
url
:
''
,
[color
=
????
listData
[
{
??????
"id"
1
"placeName"
:
"测试地址1"
"placeImageUrl"
""
"placeOpenTime"
1506200400
"placeCloseTime"
1506265200
"placeAddress"
"测试地址1啊"
"placeLongitude"
"114.08190678985596"
"placeLatitude"
"22.544808209639864"
????
}
{
2
"测试地址2"
"测试地址2啊"
"114.0938372555542"
"22.53953655390022"
{
3
"测试地址3"
1506243600
"测试地址3啊"
"114.05454"
"22.52291"
}
]
scale
'
15
Height
0
controls
40
latitude
longitude
markers
[]
??
??
onReady
function
(
e
)
{
????
/
/
使用 wx.createMapContext 获取 map 上下文
this.mapCtx
wx.createMapContext
'myMap'
)
onLoad
{
var
that
this;
????
that
.setData
{
??????
app.globalData.
url
)
?
var
data
JSON.stringify
{
/
?? page
pageSize
10
request
{
/
???? placeLongitude
app.globalData.longitude
placeLatitude
app.globalData.latitude
userId
app.globalData.userId
/
?? }
/
)
?
wx.getLocation
{
??????
type
'gcj
02
返回可以用于wx.openLocation的经纬度
success
res
)
=
>
{
????????
console.
log
;
????????
{
??????????
:
.getSchoolMarkers
)
12
res.longitude
res.latitude
????????
)
??????
}
;
?
wx.getSystemInfo
{
{
????????
设置map高度,根据当前设备宽高满屏显示
{
??????????
view
{
????????????
res.windowHeight
??????????
}
)
}
)
bindcallouttap
{
(
"头上文字被点击"
)
markertap
{
"定位的点被点击"
)
controltap
{
"111"
)
this.moveToLocation
)
getSchoolMarkers
{
?
var market
[];
?
for
let
item
of
this.
data
.listData
{
?
let marker
1
this.createMarker
(
item
;
?
market.push
marker
)
}
"market==========="
market
)
return
market;
moveToLocation
{
this.mapCtx.moveToLocation
)
strSub
a
{
var str
a.split
"."
1
];
str
str.substring
0
str.length
-
)
]
+
'.'
str;
createMarker
point
{
?
let latitude
this.strSub
point.placeLatitude
;
let longitude
point.placeLongitude;
let marker
=
{
iconPath
"../images/here.png"
id
point.
id
||
name
point.placeName || ''
title
label
{
x
-24
y
-26
????????
content
point.placeName
width
50
height
callout
{
fontSize
14
bgColor
"#FFF"
borderWidth
borderColor
"#CCC"
padding
4
display
"ALWAYS"
textAlign
"center"
}
;
marker;
}
)