Angular google map map-control更改位置

时间:2016-04-01 05:54:25

标签: angularjs angular-google-maps

我正在使用有角度的谷歌地图,默认情况下,放大 - 缩小选项会出现在右下角,但我需要将该控件放在左下角。它可以在谷歌地图api完成,但我使用角谷歌地图。并且在定位地图控件方面面临困难。

1 个答案:

答案 0 :(得分:2)

angular-google-maps docs所示,您可以通过options属性将MapOptions对象传递给指令:

<ui-gmap-google-map center="map.center" zoom="map.zoom" options="map.options"></ui-gmap-google-map>

并且MapOption可以包含ZoomControlOptions

检查以下代码段:

angular.module('appMaps', ['uiGmapgoogle-maps'])
  .controller('mainCtrl', function($scope) {
    $scope.map = {
      center: {
        latitude: 51.219053,
        longitude: 4.404418
      },
      zoom: 14,
      options: {
        scrollwheel: false,
        zoomControlOptions: {
          position: google.maps.ControlPosition.BOTTOM_LEFT
        }
      }
    };
  });
#map_canvas {
  width: 100%;
  height: 100%;
}
.angular-google-map-container {
  height: 400px;
}
<html ng-app="appMaps">

<head>
  <meta charset="utf-8">
  <title>Map</title>
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.js"></script>
  <script src="//rawgit.com/lodash/lodash/3.10.1/lodash.min.js"></script>
  <script src='//maps.googleapis.com/maps/api/js?sensor=false'></script>
  <script src="//rawgit.com/nmccready/angular-simple-logger/master/dist/angular-simple-logger.js"></script>
  <script src="//rawgit.com/angular-ui/angular-google-maps/master/dist/angular-google-maps.min.js"></script>
</head>

<body>
  <h1 class="title">Google Maps Example</h1>
  <div id="map_canvas" ng-controller="mainCtrl">
    <ui-gmap-google-map center="map.center" zoom="map.zoom" options="map.options"></ui-gmap-google-map>
  </div>
</body>

</html>