openlayers怎么通过坐标画点

2025-03-21 13:43:26
推荐回答(1个)
回答(1):

您好,很高兴为您解答。

页面发起异步请求;服务端程序将请求结果处理成GeoJSON串回传至请求页面;请求页面通过OpenLayers提供的OpenLayers.Format.GeoJSON解析GeoJSON串,将结果展现到地图上。

//初始地图
function init(){
......
vectors = new OpenLayers.Layer.Vector(...);
geojson = new OpenLayers.Format.GeoJSON();
map.addLayer(vectors);
}
//通过DWR异步取得GeoJSon串,交由OpenLayers.Format.GeoJSON来处理.
function locorie(){
//异步发出请求
dwrService.orie(orieSeri,function(data){
//通过OpenLayers.Format.GeoJSON处理服务端提供的GenJSon串
var features = geojson.read(data,"FeatureCollection");
if(features) {
//将结果展示到地图上
vectors.addFeatures(features);
}
});
}
//十秒更新一次数据
function startOrie(){
var t=setTimeout("locorie();startOrie();",10000);
}
提问者评价
谢谢!