Openlayers 5.错误。 “ a.U不是函数”

时间:2018-09-20 19:49:24

标签: openlayers

我设法在解决方案中搜索多个错误,但是这次,我找不到它。 我完全想尝试标记一个图层。

var vectorSourceMunicipiosAnno = new ol.source.Vector({
  features: (new ol.format.GeoJSON()).readFeatures(GeoJSON_MunicipiosAnno)
});

 var createTextStyleMunicipiosAnno = function(feature) {
 var textAlign = 'center';
 var textBaseline = 'middle';
 var font = feature.get('FontName');
 var size = feature.get('FontSize');
 var text = feature.get('TextString');
 var weight = 'bold';

return new ol.style.Text({
    textAlign: textAlign,
    textBaseline: textBaseline,
    font: weight + ' ' + size + ' ' + font,
    text: text
  });
};

function pointStyleFunctionMunicipiosAnno(feature) {
return new ol.style.Style({
  text: createTextStyleMunicipiosAnno(feature)
});
}

var Layer_MunicipiosAnno = new ol.layer.Vector({
 source: vectorSourceMunicipiosAnno,
 style: pointStyleFunctionMunicipiosAnno,
 zIndex:9
});

我正在使用此代码,它会返回此错误:

TypeError: a.U is not a function

编辑: 完整的GeoJSON是这样的:

var GeoJSON_MunicipiosAnno = {
"type": "FeatureCollection",
"name": "MunicipiosAnno",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::3857" } },
"features": [ 
{ "type": "Feature", "properties": { "TextString": "BARLOVENTO", "FontName": "Georgia", "FontSize": 7.0, "ORIG_FID": 1 }, "geometry": { "type": "Point", "coordinates": [ -1983881.293563810177147, 3352182.7142772404477 ] } },
{ "type": "Feature", "properties": { "TextString": "BREÑA ALTA", "FontName": "Georgia", "FontSize": 7.0,"ORIG_FID": 2 }, "geometry": { "type": "Point", "coordinates": [ -1981577.467358340276405, 3332086.66172163747251 ] } },
{ "type": "Feature", "properties": { "TextString": "BREÑA BAJA", "FontName": "Georgia", "FontSize": 7.0, "ORIG_FID": 3 }, "geometry": { "type": "Point", "coordinates": [ -1978025.2709335826803, 3330237.95754898712039 ] } },
{ "type": "Feature", "properties": { "TextString": "FUENCALIENTE DE LA PALMA", "FontName": "Georgia", "FontSize": 7.0, "ORIG_FID": 4 }, "geometry": { "type": "Point", "coordinates": [ -1987322.057562422240153, 3312660.19196065235883 ] } },
{ "type": "Feature", "properties": { "TextString": "GARAFÍA", "FontName": "Georgia", "FontSize": 7.0, "ORIG_FID": 5 }, "geometry": { "type": "Point", "coordinates": [ -1994075.11441697110422, 3350492.464456994086504 ] } },
{ "type": "Feature", "properties": { "TextString": "EL PASO", "FontName": "Georgia", "FontSize": 7.0, "ORIG_FID": 7 }, "geometry": { "type": "Point", "coordinates": [ -1988537.161246441537514, 3335500.083406003192067 ] } },
{ "type": "Feature", "properties": { "TextString": "PUNTAGORDA", "FontName": "Georgia", "FontSize": 7.0, "ORIG_FID": 8 }, "geometry": { "type": "Point", "coordinates": [ -2001116.067485597683117, 3345724.324515521060675 ] } },
{ "type": "Feature", "properties": { "TextString": "PUNTALLANA", "FontName": "Georgia", "FontSize": 7.0, "ORIG_FID": 9 }, "geometry": { "type": "Point", "coordinates": [ -1977195.865776713006198, 3343523.173676051199436 ] } },
{ "type": "Feature", "properties": { "TextString": "SAN ANDRÉS Y SAUCES", "FontName": "Georgia", "FontSize": 7.0, "ORIG_FID": 10 }, "geometry": { "type": "Point", "coordinates": [ -1981327.096204850357026, 3347296.164486307650805 ] } },
{ "type": "Feature", "properties": { "TextString": "SANTA CRUZ DE LA PALMA", "FontName": "Georgia", "FontSize": 7.0, "ORIG_FID": 11 }, "geometry": { "type": "Point", "coordinates": [ -1982715.020592568209395, 3338692.855779264587909 ] } },
{ "type": "Feature", "properties": { "TextString": "TAZACORTE", "FontName": "Georgia", "FontSize": 7.0, "ORIG_FID": 12 }, "geometry": { "type": "Point", "coordinates": [ -1995174.732208782806993, 3328068.346556198783219 ] } },
{ "type": "Feature", "properties": { "TextString": "TIJARAFE", "FontName": "Georgia", "FontSize": 7.0, "ORIG_FID": 13 }, "geometry": { "type": "Point", "coordinates": [ -1997558.726210756460205, 3339280.945627790875733 ] } },
{ "type": "Feature", "properties": { "TextString": "VILLA DE MAZO", "FontName": "Georgia", "FontSize": 7.0, "ORIG_FID": 14 }, "geometry": { "type": "Point", "coordinates": [ -1981419.954465529881418, 3322790.338938457425684 ] } },
{ "type": "Feature", "properties": { "TextString": "LOS LLANOS DE ARIDANE", "FontName": "Georgia", "FontSize": 10.0, "ORIG_FID": 16 }, "geometry": { "type": "Point", "coordinates": [ -1992321.857755252858624, 3323519.092874824535102 ] } }
]
};

0 个答案:

没有答案