1
var map;
var vectors;
var point;
var drag;
在地圖上的任何長和緯度可以使用OpenStreetMap的點沒有顯示張開層
function mapCreate(lon,lat){
map = new OpenLayers.Map("map1");
var osm = new OpenLayers.Layer.OSM();
//create a vector
vectors = new OpenLayers.Layer.Vector("Vector Layer");
map.addLayer(osm);
var center = new OpenLayers.LonLat(lon,lat).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
);
分配經緯度長到點
point = new OpenLayers.Geometry.Point(lat,lon);
添加指向矢量
vectors.addFeatures([new OpenLayers.Feature.Vector(point)]);
map.setCenter(center, 15);
//add vectors to map
map.addLayer(vectors);
}
我錯過了什麼嗎?
point = new OpenLayers.Geometry.Point(center.lon,center.lat); Point的構造函數需要一個OpenLayers.LonLat lon和lat。 – Paul