<body>
<div id="map_container">
</div>
<script>
const map = new ol.Map({
target: 'map_container',
layers: [TianDiMap_vec, TianDiMap_cva],
view: new ol.View({
projection: 'EPSG:4326',
center: [0, 0],
zoom: 2
})
})
const icon_text = new ol.style.Style({
text: new ol.style.Text({
offsetX: 0,
offsetY: 10,
font: 'normal 12px 微软雅黑',
text: '武汉市',
fill: new ol.style.Fill({
color: '#333'
}),
stroke: new ol.style.Stroke({
color: "#ff2d51",
width: 2
})
}),
image: new ol.style.Icon({
anchor: [0.5, 60],
anchorOrigin: 'top-right',
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
offsetOrigin: 'top-right',
scale: 0.5,
opacity: 0.75,
src: '../image/location.png',
})
})
const point = new ol.Feature({
geometry: new ol.geom.Point([114, 36]),
})
point.setStyle(icon_text)
const source = new ol.source.Vector({
features: [point],
wrapX: false
})
const vector = new ol.layer.Vector({
source: source
})
map.addLayer(vector)
</script>
</body>