Я создаю слой карты со следующим кодом:
var GeoJSON = {};
GeoJSON.type = "FeatureCollection";
GeoJSON.features = [];
var iconStyle = new ol.style.Style({
image: new ol.style.Icon(({
anchor: [0.5, 46],
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
opacity: 0.75,
src: "~/icons/delivery-truck.png"
}))
});
for (var i = 0; i < data.length; i++) {
var machineGeoObject = {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [data[i]["longitude"], data[i]["latitude"]],
},
"properties": data[i],
"style": iconStyle
}
GeoJSON.features.push(machineGeoObject);
} //end of loop
var format = new ol.format.GeoJSON({
featureProjection: "EPSG:3857"
});
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
features: format.readFeatures(GeoJSON)
})
});
map.addLayer(vector);
Ошибки нет. Когда я вызываю map.getLayers()
в консоли, я вижу добавленный слой. Свойство слоя «видимый» истинно. Почему я не вижу на карте отмеченных местоположений значков? Почему я вижу только голую карту?