vue3+SuperMap iClient for Leaflet按照官网流程安装并全局引入相关包,然后刚开始报“ Cannot read properties of undefined (reading 'tiledMapLayer')”,然后换成按需引入又报“Cannot read properties of undefined (reading 'lat')”错误。
<template>
<div id="map"></div>
</template>
<script setup>
import { onMounted } from "vue";
import L from "leaflet";
import { TiledMapLayer } from "@supermap/iclient-leaflet";
function addMapA() {
var url =
"
https://iserver.supermap.io/iserver/services/map-world/rest/maps/World";
var map = L.map("map", {
crs: L.CRS.EPSG4326,
center: [0, 0],
maxZoom: 18,
zoom: 1,
});
var layer = new TiledMapLayer(url);
layer.addTo(map);
}
onMounted(() => {
addMapA();
});
</script>