Neha
Neha

Reputation: 85

Angular google map map-control change position

I am using angular google map and by default zoom in - out option is coming on bottom right corner, but i need that control to be placed in bottom left corner. It can be done in google map api but i am using angular google maps. And facing difficulty in positioning map controls.

Upvotes: 2

Views: 2316

Answers (1)

beaver
beaver

Reputation: 17647

As indicated in angular-google-maps docs you can pass MapOptions object to the directive via options attribute:

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

and the MapOption can contain the ZoomControlOptions.

Check the snippet below:

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>

Upvotes: 2

Related Questions