Properties Openlayers 3:Get";“未定义”;用于一层中的geojson属性
我试图从geojson文件中获取属性Properties Openlayers 3:Get";“未定义”;用于一层中的geojson属性,properties,openlayers-3,geojson,Properties,Openlayers 3,Geojson,我试图从geojson文件中获取属性“SCHULNAME” 以下是geojson文件的一个片段: {"type":"FeatureCollection", "crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:OGC:1.3:CRS84"}}, "features":[{"type":"Feature","properties":{"spatial_name":"01A01", "spatial_alias":"1. S
“SCHULNAME”
以下是geojson文件的一个片段:
{"type":"FeatureCollection",
"crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:OGC:1.3:CRS84"}},
"features":[{"type":"Feature","properties":{"spatial_name":"01A01",
"spatial_alias":"1. Schulpraktisches Seminar (S) Mitte",
"spatial_type":"Point",
"SCHULNAME":"1. Schulpraktisches Seminar (S) Mitte",
"SCHULART":"Schulpraktisches Seminar",
"TRAEGER":"Bezirk",
"ZWEIG_01":"Schulpraktisches Seminar",
"ZWEIG_02":null,
"ZWEIG_03":null,
"ZWEIG_04":null,
"BEZIRK":"Mitte",
"ORTSTEIL":"Wedding",
"PLZ":"13353",
"ADRESSE":"Tegeler Str. 16",
"TELEFON":"4677779713",
"FAX":"4677779720",
"EMAIL":"<a href=\"mailto:1.sps-mitte@gmx.de\">1.sps-mitte@gmx.de</a>",
"INTERNET":null,"LEITUNG":null},
"geometry":{"type":"Point",
"coordinates":[13.35812948892163,52.54071751171907]}},...
我在这里遗漏了什么?我发现了问题的原因,但我希望您能解释一下,因为我不明白为什么会发生这种情况 我为第一个geojson层创建了一个
ol.source.Cluster
,并将该ol.layer.Vector
层的源引用到该集群源:
var schoolCluster = new ol.source.Cluster({
source:new ol.source.Vector({
url: 'Schools.geojson',
format: new ol.format.GeoJSON(),
})
});
var Schools = new ol.layer.Vector({
source: schoolCluster,
style: iconStyleSchools
});
但不知何故,只有当我在向量层中直接引用源时,它才能获得属性,而没有任何类似于以下的簇:
var Schools = new ol.layer.Vector({
source:new ol.source.Vector({
url: 'Schools.geojson',
format: new ol.format.GeoJSON(),
}),
style: iconStyleSchools
});
有了这段代码,我可以从geojson文件中获得我想要的所有属性,不再得到任何未定义的
。有人能解释一下原因吗?您确定您获得了预期的功能吗?正如我前面所说的:坐标显示正确。因此,我非常肯定能够获得预期的功能。@user3725485位这些坐标只是单击事件的坐标。可能还有其他功能可以匹配吗?@Alvin Lindstam否。我指的是创建的html文件中的坐标,而不是弹出窗口的位置。你的意思是‘var坐标’,但我用‘var printCoord’得到的特征坐标是的。如何将GeoJSON转换为ol特性?功能的属性中是否有任何值?
var schoolCluster = new ol.source.Cluster({
source:new ol.source.Vector({
url: 'Schools.geojson',
format: new ol.format.GeoJSON(),
})
});
var Schools = new ol.layer.Vector({
source: schoolCluster,
style: iconStyleSchools
});
var Schools = new ol.layer.Vector({
source:new ol.source.Vector({
url: 'Schools.geojson',
format: new ol.format.GeoJSON(),
}),
style: iconStyleSchools
});