我在单独的文件中设置了不同的组件,但是当我聚合搜索输入时,我在本地收到此错误:
angular.js:13424 Error: Map container not found.
在 plunker 中:
angular.js:13424Error: Map container is already initialized.
奇怪的是地图运行良好。怎么了?
我在单独的文件中设置了不同的组件,但是当我聚合搜索输入时,我在本地收到此错误:
angular.js:13424 Error: Map container not found.
在 plunker 中:
angular.js:13424Error: Map container is already initialized.
奇怪的是地图运行良好。怎么了?
您已将地图初始化了两次,一次在 中BaseMapController
,另一次在inputController
.
中BaseMapController
,替换
_map = BaseMapService.mapElement();
和
$scope.map = BaseMapService.mapElement();
_map=$scope.map;
中inputController
,替换
BaseMapService.AutoComplete(_searchInputId).bindTo('bounds', BaseMapService.mapElement());
和
BaseMapService.AutoComplete(_searchInputId).bindTo('bounds', $scope.map);
希望能解决你的问题。
更新:
在您的演示中,自动完成工作正常,但未正确绑定到地图。例如,如果您搜索任何地方,您将不会在地图上找到该地方。我刚刚解决了您提到的错误。
对于自动完成,您使用过 google API,对于自动完成,您basemap
使用过Leaflet
.
我的建议是:不要混合使用这两种方法,而是使用Leaflet.GoogleAutocomplete或Google Maps JavaScript API