在现有的ng-map上获取搜索框

Art*_*ter 0 javascript google-maps angularjs

我需要将搜索框放置到ng-map。我从这里尝试解决方案

https://google-developers.appspot.com/maps/documentation/javascript/examples/geocoding-simple

但我无法使其与ng-map一起使用。如果有人可以帮助我,这是我的朋克。我需要两个解决方案,一个是放置标记并获取坐标(此解决方案有效),第二个是搜索框,我对此有问题。并且有什么方法可以限制地图上可供选择的区域,例如本网站上的地图。抱歉我的英语不好。谢谢

  [1]: https://plnkr.co/edit/sKOaZOX6FbJwDdf3Po5Z?p=preview
Run Code Online (Sandbox Code Playgroud)

Vad*_*hev 5

ng-map库支持Place Autocomplete,有关详细信息,请参见places-auto-complete.js

以下是启用位置自动完成功能的更改列表:

1)places像这样加载库:<script src="//maps.google.com/maps/api/js?key=--KEY--&libraries=places"></script>

2)input在页面上放置元素: <input places-auto-complete types="['geocode']" on-place-changed="placeMarker()" />

3)实现on-place-changed处理程序,例如:

$scope.placeMarker = function(){
    var place = this.getPlace();  //get selected place 
    //...
};
Run Code Online (Sandbox Code Playgroud)

这是启用了搜索框的分叉式矮人车