1
即时通讯工作在谷歌地图的事情,我需要访问setZoom方法时点击自定义按钮。问题是setZoom()变得不确定。我已经加载了所有的依赖项(地图渲染和我的$ scope.zoom运行)。我已经测试过了。任何人都知道该怎么办?有角度的谷歌地图。访问地图默认功能
HTML:
<div ng-app="app" ng-controller="MapController">
<ui-gmap-google-map center="map.center" zoom="map.zoom">
<ui-gmap-map-control template="../pages/partials/map-controls.html" controller="MapController" position="RIGHT_BOTTOM">
</ui-gmap-map-control>
</ui-gmap-google-map>
</div>
JS:
$scope.map = {
center: {
latitude: 67.855800,
longitude: 20.225282
},
zoom: 13,
options: {
scrollwheel: false,
disableDefaultUI: true,
streetViewControl: false,
backgroundColor: '#f2f2f2'
}
};
$scope.zoom = function($event) {
$event.preventDefault();
//the problem is here. $scope.map.setZoom() gets undefined.
$scope.map.setZoom(9);
};
谢谢!但我得到“map.control是未定义的”。 – user2952238
我已经更新了您的示例以注入'map.control',当您尝试调用它时,它不应该是未定义的 –
我实现了更改并执行了此操作:console.log($ scope.map.control);其中得到undefined .. – user2952238