function initMap() {
map.value = new Map({
target: 'map',
layers: [
new Tile({
source: new XYZ({
url: 'http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}',
})
}),
new Tile({
source: new XYZ({
url: 'https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}.png',
}),
minResolution: 2000,
maxResolution: 20000
})
],
view: new View({
center: [653600, 5723680],
zoom: 5
})
})
}
const overlay = ref(null)
const area = reactive({
India: [68.17665, 7.96553, 97.40256, 35.49401],
Argentina:[-73.41544, -55.25, -53.62835, -21.83231],
Nigeria: [2.6917, 4.24059, 14.57718, 13.86592],
Sweden: [11.02737, 55.36174, 23.90338, 69.10625]
})
function initMap() {
overlay.value = new Tile({
extent: area.India,
preload: Infinity,
source: new XYZ({
url: 'http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}',
}),
})
map.value = new Map({
target: 'map',
layers: [
new Tile({
source: new TileJSON({
url: 'https://maps.gnosis.earth/ogcapi/collections/NaturalEarth:raster:HYP_HR_SR_OB_DR/map/tiles/WebMercatorQuad?f=tilejson',
crossOrigin: 'anonymous'
})
}),
overlay.value
],
view: new View({
projection: "EPSG:4326",
center: [0, 0],
zoom: 1
})
})
}
function replaceTheRegion(data) {
overlay.value.setExtent(area[data])
}
let iconFeature = new Feature({
geometry: new Point([100, 36]),
name: '你点我了',
population: 4000,
rainfall: 500
})
let iconStyle = new style.Style({
image: new style.Icon({
anchor: [0.5, 46],
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
src: iconPng
})
})
iconFeature.setStyle(iconStyle)
let vectorSource = new sourceVector({
features: [iconFeature]
})
let vectorLayer = new layerVecor({
source: vectorSource
})
map.addLayer(vectorLayer)