Im using Ol V5.3.1 and working with asp mvc and this is my code for getting the map and a marker or any icon in a specific location to show my location
var view = new ol.View({
center: ol.proj.fromLonLat([51.40876293182373, 35.757448286487595]),
zoom: 12,
maxZoom: 19,
});
var rasterLayer = new ol.layer.Tile({
source: new ol.source.OSM()
});
var VactorLayer = new ol.layer.Vector({
source: new ol.source.Vector({
features: new ol.Feature({
geometry: new ol.geom.Point([51, 35]),
name: 'Null Island',
population: 4000,
rainfall: 500,
setStyle: new ol.style.Style({
image: new ol.style.Icon({
anchor: [0.5, 46],
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
src: "http://openlayers.org/en/v3.7.0/examples/data/icon.png",
})
})
})
})
});
var map = new ol.Map({
target: 'map',
controls: new ol.control.defaults({
attributionOptions: {
collapsible: false
}
}),
layers: [rasterLayer, VactorLayer],
view: view,
});
everything is good and showing the tiles and map with my location and there's no any error in console of my browser for javascripts but just dont show the icon and marker as this is an example of openlayer example working with vector layer at Example_Marker
i also find another way to put marker with overlay in this Example as i code this in below
var marker = new ol.Overlay({
position: pos,
positioning: 'center-center',
element: document.getElementById('marker'),
stopEvent: false
});
var pos = new ol.proj.fromLonLat([51, 35]);
map.addOverlay(marker);
but also not showing this one
any suggestion?