如何将自定义属性/属性应用于标记并将事件侦听器应用于标记。我们已经在Google地图中实现了这一结果,但是在百度地图中实现这一目标却遇到了障碍。
$(document).ready(function(){
myDefault();
})
function myDefault(){
var locations = [
{
"id": 34304,
"center": {
"north": 28.351149653852,
"south": 28.349149653852,
"east": 77.291699928999,
"west": 77.289699928999
},
"color": "black",
"username": "Mikado Tools",
"mobile": "",
"email": "mikadotools@gmail.com",
"created_adm": "Arun-Kaw",
"sml_category": "L2",
"sales_sml_category": "",
"userid": "307",
"lat": "28.350149653851986",
"lng": "77.29069992899895"
},
{
"id": 68,
"center": {
"north": 19.953741017497,
"south": 19.951741017497,
"east": 73.73060985594,
"west": 73.72860985594
},
"color": "black",
"username": "Lucy Electric India Pvt. Ltd.",
"mobile": "",
"email": "Devidas.Darkonde@lucygroup.com",
"created_adm": "MOHAMMED-SAMI",
"sml_category": "L2",
"sales_sml_category": "",
"userid": "168",
"lat": "19.952741017496933",
"lng": "73.72960985593978"
}];
var map = new BMap.Map("container");
map.centerAndZoom(new BMap.Point(73.9312884, 18.5190349), 8);
map.enableScrollWheelZoom(true);
var icon = new BMap.Icon('map/customer.png', new BMap.Size(30 , 32),
{
anchor: new BMap.Size(10, 30)
});
for(var i=0; i < locations.length; i++){
var username = locations[i].username+locations[i].created_adm;
var mkr = new BMap.Marker( new BMap.Point(locations[i].lng,locations[i].lat),{
icon: icon,
title:locations[i].username,
id:locations[i].id
});
map.addOverlay(mkr);
console.log(mkr);
var infoWindow = new BMap.InfoWindow(info);
mkr.addEventListener('mouseover', function(event){
})
}
}
我想在相应的悬停上显示相应的用户名和电子邮件