Javascript OpenstreetMap的拖动标记不工作
如何使用javascript在openstreetMap中拖动markar 我使用了下面的代码,这些代码无法正常工作,以及如何使用javascript在opestreetMap中实现markar的InfoWindow var marker = new OpenLayers.Layer.Markers({ position: new OpenLayers.LonLat(lon, lat).transform(fromProjection, toProjection), map: map, draggable: true, title: "static marker" }); var marker=新的OpenLayers.Layer.Markers({ 位置:新OpenLayers.LonLat(lon,lat).变换(从投影,到投影), 地图:地图, 真的, 标题:“静态标记” });Javascript OpenstreetMap的拖动标记不工作,javascript,openlayers,openstreetmap,Javascript,Openlayers,Openstreetmap,如何使用javascript在openstreetMap中拖动markar 我使用了下面的代码,这些代码无法正常工作,以及如何使用javascript在opestreetMap中实现markar的InfoWindow var marker = new OpenLayers.Layer.Markers({ position: new OpenLayers.LonLat(lon, lat).transform(fromProjection, toProject
创建新的矢量层:
Layer.MARKER = new OpenLayers.Layer.Vector("Marker Layers", {
styleMap: new OpenLayers.StyleMap({
'default': {
externalGraphic: "${URL}",
graphicWidth:50,//pixel
graphicHeight:50//pixel
}
}
)
});
添加地图:
map.addLayer(Layer.MARKER);
拖动控制添加
Control.DragText = new OpenLayers.Control.DragFeature(Layer.MARKER);
map.addControl(Control.DragText);
激活控制:
Control.DragText.activate();
//Deactive Control.DragText.deactivate();
最后添加标记:
var marker= new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(lon, lat));
marker.attributes = {
URL: "marker_url"
};
Layer.MARKER.addFeatures([marker]);
描述“工作不正常”。