Gil*_*lit 4 javascript mapping popup markers openlayers
LoadPin是一种向地图添加标记的功能.它在第一次调用时初始化图层.map是一个openlayers地图对象.
但是使用map.removeLayer("markers")或"Markers"不会从地图中删除标记.我看到提到一个破坏操作来做到这一点,但无法找到.
AND,如何删除弹出窗口?
var markers = null
function LoadPin(LL, name, description) {
var size = new OpenLayers.Size(36, 47);
var offset = new OpenLayers.Pixel(-(size.w / 2), -size.h);
var icon = new OpenLayers.Icon('http://www.waze.co.il/images/home.png', size, offset);
if (markers == null) {
markers = new OpenLayers.Layer.Markers("Markers");
map.addLayer(markers);
}
var marker = new OpenLayers.Marker(LL, icon)
markers.addMarker(marker);
var bounds = markers.getDataExtent();
map.zoomToExtent(bounds);
map.addPopup(new OpenLayers.Popup.FramedCloud("test", LL, null,
"<div style='font-family:Arial,sans-serif;font-size:0.8em;'>" + name + "<br>" + description + "</div>",
anchor = null, true, null));
}
Run Code Online (Sandbox Code Playgroud)
Ham*_*ish 10
您可以使用以下标记从标记图层中删除单个标记:
markers.removeMarker(marker);
Run Code Online (Sandbox Code Playgroud)
使用标记去除整个图层应该通过以下方式实现:
markers.destroy();
Run Code Online (Sandbox Code Playgroud)
您应该可以删除弹出窗口:
map.removePopup(popup);
Run Code Online (Sandbox Code Playgroud)
其中popup是先前创建的Popup对象.
Chr*_*ssy 10
我知道这篇文章很旧但是要删除标记图层列表中的所有标记使用:
markerLayer.clearMarkers();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20972 次 |
| 最近记录: |