I want to create a web app which is using OpenLayer 6.5. I want to mark some locations dynamically so I can't keep some ".geojson" files on my server. What should I do?
I'm trying to create a VectorSource from a JavaScript GeoJson object but it always shows a false location! What's wrong with this code?
var GeoJSONObject = {
type: "FeatureCollection",
features: [
{
type: "Feature",
properties: {},
geometry: {
type: "Point",
coordinates: [
70.33447265624999,
55.541064956111036
]
}
}
]
};
var vectorSource = new ol.source.Vector({
features: new ol.format.GeoJSON().readFeatures(GeoJSONObject)
});
var vectorLayer = new ol.layer.Vector({
renderMode: 'image',
source: vectorSource,
visible: true,
title: "Plant",
style: new ol.style.Style({
image: circleStyle
})
});
map.addLayer(vectorLayer);
I solved this problem by using ol.style.Icon instead of Vector! If you have this problem, look at this: https://openlayers.org/en/latest/examples/icon.html