我有一个刺激,我从服务器,我需要循环它。这个字符串实际上是我希望使用openLayers在地图中可视化的位置的地理位置。以下是返回字符串的示例:
{crs:
{"type":"name",
"properties":{
"name":"ESPG:4326"
},
},
"features":[{"properties":{
"image":"IMAGE1"},
"type":"Feature",
"geometry":{
"type":"Point",
"coordinates":[0,0]
}},{"properties":{
"image":"IMAGE2"},
"type":"Feature",
"geometry":{
"type":"Point",
"coordinates":[10,10]
}},{"properties":{
"image":"IMAGE3"},
"type":"Feature",
"geometry":{
"type":"Point",
"coordinates":[75,99]
}}]
,type:"FeatureCollection"
}
正如您所看到的feature
features
properties
有geometry
和layer
。我想创建一个新的//map is the actual map where the images load
//responseText is the String that I get from the server
//predefinedImage is actually a predefined image that I use as icon for the points.
//If I complitelly remove the "style" from geojson_layer it sets the image to a default value.
var geoJSONsource = new ol.source.Vector({
features: (new ol.format.GeoJSON()).readFeatures(responseText)
});
geojson_layer = new ol.layer.Vector({
source: geoJSONsource,
style: predefinedImage
});
map.addLayer(geojson_layer);
(ol.layer.Vector),对于每个要素元素,将使用相应的坐标和图像绘制一个点。使用以下代码,我可以设法使用预定义的图像绘制地图中的所有点。我想我应该遍历这个字符串并获取坐标和图像,并以某种方式创建一个图层(或许多图层?),并将这些值作为源和样式相应地。任何想法??谢谢!
$myParams[] = array('nome_Campo' => 'Barcode', 'valore' => $barcode);
$myParams[] = array('nome_Campo' => 'DOC_DATE min', 'valore' => $datai);
$myParams[] = array('nome_Campo' => 'DOC_DATE max', 'valore' => $newdate);
$params = array(
"arg0" => $sasAliasSP,
"arg1" => $sasAliasDA,
"arg2" => "",
"arg3" => $myParams,
"arg4" => "",
"arg5" => "0",
"arg6" => "1000"
);
答案 0 :(得分:1)
这可能会对您有所帮助:
https://gis.stackexchange.com/a/95389/77349
你应该修改这一行:
externalGraphic: 'marker.png',
类似
externalGraphic: this.image,
希望这有帮助!