首页 > 解决方案 > vue2-leaflet-locatecontrol 错误:max2 未定义

问题描述

我在我的 vue 组件中使用 vue2-leaflet。我在使用 vue2-leaflet-locationcontrol 时遇到问题。当我允许浏览器允许控制台中的位置访问时,我收到错误

类型错误:max2 未定义

这是组件中的示例代码:

<l-map :zoom="zoom" :center="center" :bounds="bounds">
   <l-tile-layer :url="url" :attribution="attribution" :no-wrap="true"></l-tile-layer>
   <l-marker :lat-lng="marker" :draggable="true" @update:lat-lng="updateMarker"></l-marker>
   <v-geosearch :options="geosearchOptions" @showlocation="showLocation"></v-geosearch>
   <v-locatecontrol />
</l-map>

在组件中导入

import { LMap, LTileLayer, LMarker } from "vue2-leaflet";
import { OpenStreetMapProvider } from "leaflet-geosearch";
import VGeosearch from "vue2-leaflet-geosearch";
import VLocatecontrol from "vue2-leaflet-locatecontrol";

main.js中导入

import L from 'leaflet';

L.Icon.Default.imagePath = '/themes/storefront/assets/public/image/';
L.Icon.Default.mergeOptions({
    iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png').split("/")[5],
    iconUrl: require('leaflet/dist/images/marker-icon-2x.png').split("/")[5],
    shadowUrl: require('leaflet/dist/images/marker-shadow.png').split("/")[5],
});
import 'leaflet/dist/leaflet.css';
import 'leaflet-geosearch/assets/css/leaflet.css';

我做错了什么?

标签: vuejs2leaflet

解决方案


推荐阅读