我使用 objectManager 在地图上显示标记。单击时未打开单个标签的气球。单击分组气球时,它会正常显示。这是地图调用:
var myMap,
geoObjects,
objectManager,
arr_check = [];
ymaps.ready(init);
function init()
{
myMap = new ymaps.Map('map', {
center: [".$last_gps."],
zoom: 14,
type: 'yandex#satellite'
}, {
searchControlProvider: 'yandex#search'
});
objectManager = new ymaps.ObjectManager({
clusterize: true,
gridSize: 32,
clusterDisableClickZoom: true
});
objectManager.objects.options.set('preset', 'islands#grayDotIcon');
objectManager.clusters.options.set('preset', 'islands#grayClusterIcons');
myMap.geoObjects.add(objectManager);
$.ajax({
url: 'panel_json.php',
type: 'post',
dataType: 'json',
data: {arrp:arr_check}
}).done(function(data) {
objectManager.add(data);
geoObjects = ymaps.geoQuery(data)
.applyBoundsToMap(myMap, {
checkZoomRange: true
});
});
myMap.geoObjects.add(objectManager);
};
我接受这样的 JSON:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": "55.831903, 37.411961"
},
"properties": {
"balloonContent": "<a href=\'more.php?id=1\'>Описание</a>",
"hintContent": "Описание",
"clusterCaption": "Описание"
},
"options": {
"preset": "islands#icon",
"iconColor": "#00AA00"
}
}
]
}
这里举了一个例子https://tech.yandex.ru/maps/jsbox/2.1/object_manager
ObjectManager 的数据必须具有每个地理对象的唯一 ID 字段。
将坐标写成两个元素的数组也是正确的:
示例:https ://jsfiddle.net/10mqLvfw/