角度验证:8
Package.json中的版本:
"leaflet": "1.5.1",
"leaflet-draw": "1.0.4",
"leaflet-sidebar-v2": "3.0.3",
"esri-leaflet": "2.3.2",
"leaflet-control-geocoder": "1.10.0"我有进口传单和其他类似的东西:
import * as L from 'leaflet';
import 'leaflet-draw';
import * as esri from 'esri-leaflet';
import 'leaflet-sidebar-v2';
import 'leaflet-control-geocoder';现在我必须使用或者leaflet-control-geocoder来实现这个功能,但是如果我这样写:
L.control.geocoder().addTo(map);angular crash。(在类型'typeof Control‘上不存在'geocoder’属性)我也尝试了esri-leaflet-geocoder,但它也崩溃了。
有什么解决方案吗?
发布于 2021-06-09 00:19:54
我也有同样的问题。我通过这样做修复了它
import * as L from 'leaflet';
import Geocoder from 'leaflet-control-geocoder';
...
this.map = L.map('map', {
center: [staticLatLng.lat, staticLatLng.lng],
zoom: zoomLevel
});
const GeocoderControl = new Geocoder();
GeocoderControl.addTo(this.map);
GeocoderControl.on('markgeocode', function (e) {
console.log(e);
});
...发布于 2020-01-03 17:26:34
请尝试使用大写的"C“L.Control.geocoder().addTo(map)
或者(但这应该有相同的效果)
var geocoder = new L.Control.geocoder();
map.addControl(geocoder);发布于 2020-02-19 22:52:06
我也有同样的问题。我在L.Routing.control中添加了地理编码器,它可以工作了!(实际上,VS代码仍然是Property 'Geocoder' does not exist on type 'typeof Control'),但它可以工作!:
L.Routing.control({ waypoints: [L.latLng(57.74, 11.94), L.latLng(57.6792, 11.949)], showAlternatives: true, geocoder: L.Control.Geocoder.nominatim() }).addTo(this.map);
我正在使用Angular 8,leaftlet-routing-machine插件。
https://stackoverflow.com/questions/59575551
复制相似问题