android高德marker添加点击,高德地图上添加marker,给每一个marker添加点击事件。...
高德地圖上添加marker,給每一個(gè)marker添加點(diǎn)擊事件。
高德地圖上添加marker,給每一個(gè)marker添加點(diǎn)擊事件。javascript
var watch = []
$.ajax({
type: 'GET',
dataType: 'jsonp',
url:
url +
'你的url地址',
error: function() {
alert('獲取監(jiān)控點(diǎn)信息失敗')
},
success: function(data) {
var json = data.QueryUDCAMERAINFOResponse
json = json.UDCAMERAINFOSet.UDCAMERA
$.each(json, function(index, item) {
if (json[index].LATITUDE && json[index].LONGITUDE) {
// console.log(json[index])
watch.push(json[index])
// console.log(watch)
}
})
watchMap(watch)
}
})
function watchMap(list) {
var watchList = []
// 添加多個(gè)地圖點(diǎn)標(biāo)記
for (let i = 0; i < list.length; i++) {
var temp = new AMap.Marker({
position: new AMap.LngLat(list[i].LONGITUDE, list[i].LATITUDE), // 經(jīng)緯度對(duì)象,也能夠是經(jīng)緯度構(gòu)成的一維數(shù)組[116.39, 39.9]
title: list[i].NAME,
map: map,
icon: 'imgs/sxt.png',
clickable: true
})
watchList.push(temp)
// 給每一個(gè)點(diǎn)標(biāo)記注冊(cè)點(diǎn)擊事件
AMap.event.addListener(temp, 'click', function(e) {
$('#watch').hide(300)
//獲得的數(shù)據(jù)
for (let j = 0; j < list.length; j++) {
if (this.B.title == list[j].NAME) {
// 點(diǎn)擊攝像頭標(biāo)記,切換中心坐標(biāo)
map.setCenter([list[i].LONGITUDE, list[i].LATITUDE])
var str =
'
設(shè)備信息
- 位置:??' +
list[j].NAME +
'
- 緯度:??' +
list[i].LATITUDE +
'
- 精度:??' +
list[i].LONGITUDE +
'
- 運(yùn)行狀態(tài):??正常
'>點(diǎn)擊查看
'>資產(chǎn)臺(tái)帳
// 更改彈窗口
$('#watch').html(str)
$('#watch')
.css({
left: '50%',
top: '50%'
})
.show(300)
$('#closeWatch').click(function() {
$('#watch').hide(300)
})
$('#openMp4').click(function() {
$('.playerMp4')
.css({
height: $(window).height()
})
.show(300)
$('.radio_top_title').html(list[j].NAME)
$('#watch').hide(300)
})
}
}
})
}
// 將建立的點(diǎn)標(biāo)記添加到已有的地圖實(shí)例:
map.add(watchList)
// 利用styles屬性修改點(diǎn)聚合的圖標(biāo)樣式
var styles = [
{
url: 'https://a.amap.com/jsapi_demos/static/images/blue.png',
size: new AMap.Size(32, 32),
offset: new AMap.Pixel(-16, -30)
},
{
url: 'https://a.amap.com/jsapi_demos/static/images/green.png',
size: new AMap.Size(36, 36),
offset: new AMap.Pixel(-18, -18)
},
{
url: 'https://a.amap.com/jsapi_demos/static/images/orange.png',
size: new AMap.Size(48, 48),
offset: new AMap.Pixel(-24, -45)
}
]
//添加聚合組件
map.plugin(['AMap.MarkerClusterer'], function() {
cluster = new AMap.MarkerClusterer(
map, // 地圖實(shí)例
watchList, // 海量點(diǎn)組成的數(shù)組
{
styles: styles
}
)
})
總結(jié)
以上是生活随笔為你收集整理的android高德marker添加点击,高德地图上添加marker,给每一个marker添加点击事件。...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: golang 排序_堆 堆排序 优先队列
- 下一篇: Oracle run leve,UNIX