나는 미쳐 갈 것이다. OpenLayers 2.10 Beginners Guide에서 json 파일에 저장된 기능을 표시하고지도에 기능을 추가하고 파일에 저장하려고하는 예제를 재현하려고합니다.파일을 읽고 저장하는 기능 - OpenLayers
var map;
function init(){
map = new OpenLayers.Map('map');
var options = {numZoomLevels: 3}
var floorplan = new OpenLayers.Layer.Image(
'Floorplan Map',
'temp_photos/sample-floor-plan.jpg',
new OpenLayers.Bounds(-180, -88.759, 180, 88.759),
new OpenLayers.Size(580, 288),
options
);
var roomPolygonLayer = new OpenLayers.Layer.Vector('Rooms', {
protocol: new OpenLayers.Protocol.HTTP({
url: "myFloorPlanData.json",
format: new OpenLayers.Format.GeoJSON({})}),
strategies: [new OpenLayers.Strategy.Fixed(), new OpenLayers.Strategy.Save()]
});
map.addLayers([floorplan, roomPolygonLayer]);
map.zoomToMaxExtent();
map.addControl(new OpenLayers.Control.EditingToolbar(roomPolygonLayer));
map.layers[1].onFeatureInsert = function(feature){
alert("feature id: "+feature.id);
alert("feature geometry: "+ feature.geometry);
};
}
지금까지, 내지도는, 내가 그리는 새로운 점 저장도하지만 그것이 내가 내 JSON 파일에있는 두 지점을 표시하기를 거부,지도 벡터를 그릴 수 있습니다 표시됩니다
을{
"type": "FeatureCollection",
"features": [
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[5, 63]}},
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[-48, 27]}}
]
}
JSON 파일 내 JSP 파일과 같은 폴더에, 나는
이 새로운 OpenLayers.Format.GeoJSON()에 대해 새 OpenLayers.Format.GeoJSON ({})을 바꾸어 시도하십시오 – capdragon
편집 도구 모음을 제거하고 올바르게 표시된 점 ... 같은 것을 사용할 수 없다고 생각합니다. 벡터 레이어를 사용하여 점을 표시하고 점을 그립니다. 그러나 나는 드로잉 할 새로운 기능을 저장하는 작업을 계속하고 있으며 일단 작동하게되면 여기에 답변을 게시 할 것입니다. 지금이 예제를 사용하고 있습니다. http://openlayers.org/dev/examples/vector-formats.html –