来自这个例子https://docs.mapbox.com/mapbox-gl-js/example/cluster-html/ 我已经做了类似的但是由于性能问题我想改变一些东西 它在 setPopup 上。相反,我想通过在当前逻辑中删除它来单独加载弹出窗口。看下面的代码
new Feature{
Type = "Features",
Properties = new Properties{ Title = "Marker-1",Altitude=50.00},
Geometry = new Geometry
{
Type = "Point", Coordinates = new List<double>{ 148.9819, -35.39847 }
},
},
new Feature
{
Type = "Features",
Properties = new Properties{ Title = "Marker-2",Altitude=80.00 },
Geometry = new Geometry
{
Type = "Point", Coordinates = new List<double>{ 119.06535, -22.77616 }
}
var features = mapBox.querySourceFeatures('marker-data', {
layers: ['unclustered-point']
});
for (var i = 0; i < features.length; i++) {
var coords = features[i].geometry.coordinates;
var props = features[i].properties;
if (props.cluster) continue;
//var id = props.cluster_id;
var id = features[i].properties.title;
var marker = markers[id];
if (!marker) {
var el= document.createElement('div');
el.className = props.className;
el.innerHTML = props.innerHTML;
test = props.title;
marker = markers[id] = new mapboxgl.Marker({
element: el
}).setLngLat(coords);//.setPopup(new mapboxgl.Popup().setHTML(props.title));
componentInstance.invokeMethodAsync("NotifyClickMarker",props.title);
}
newMarkers[id] = marker;
if (!markersOnScreen[id]) marker.addTo(mapBox);
}
我想知道当标记从地图上“单击”时是否有任何可能的方法来获取详细信息,然后使用 invokeMethodAsync("NotifyClickMarker",props.title); 将标记的名称/ID 从 javascript 发送到 C#这样我就可以将它用作参数值来从另一个方法调用弹出窗口。问题是单击第二个标记时它不会动态更改值。