0

我在单独的文件中设置了不同的组件,但是当我聚合搜索输入时,我在本地收到此错误:

angular.js:13424 Error: Map container not found.

在 plunker 中:

angular.js:13424Error: Map container is already initialized.

奇怪的是地图运行良好。怎么了?

代码

4

1 回答 1

0

工作演示

您已将地图初始化了两次,一次在 中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.GoogleAutocompleteGoogle Maps JavaScript API

于 2016-04-19T04:56:28.220 回答