title: Is it possible to calculate distance between two markers in angular-google-maps?
body: <p>I want to show the distance between a central <code>marker</code> to each another <code>markers</code> in its own <code>window</code>. Is there any way to calculate distance in <code>angular-google-maps</code>?</p>
  
  <p>Below is the code from <a href="https://angular-ui.github.io/angular-google-maps/#!/api/markers" rel="nofollow">here</a>.</p>
  
  <p><strong>map.html</strong></p>
  
  <pre><code>&lt;div id="map_canvas" ng-controller="mainCtrl"&gt;
      &lt;ui-gmap-google-map center="map.center" zoom="map.zoom" draggable="true" options="options" bounds="map.bounds"&gt;
          &lt;ui-gmap-markers models="randomMarkers" coords="'self'" icon="'icon'"&gt;
          &lt;/ui-gmap-markers&gt;
      &lt;/ui-gmap-google-map&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>controller.js</strong></p>
  
  <pre><code>angular.module('appMaps', ['uiGmapgoogle-maps'])
    .controller('mainCtrl', function($scope) {
      $scope.map = {
        center: {
          latitude: 40.1451,
          longitude: -99.6680
        },
        zoom: 4,
        bounds: {}
      };
      $scope.options = {
        scrollwheel: false
      };
      var createRandomMarker = function(i, bounds, idKey) {
        var lat_min = bounds.southwest.latitude,
          lat_range = bounds.northeast.latitude - lat_min,
          lng_min = bounds.southwest.longitude,
          lng_range = bounds.northeast.longitude - lng_min;
  
        if (idKey == null) {
          idKey = "id";
        }
  
        var latitude = lat_min + (Math.random() * lat_range);
        var longitude = lng_min + (Math.random() * lng_range);
        var ret = {
          latitude: latitude,
          longitude: longitude,
          title: 'm' + i
        };
        ret[idKey] = i;
        return ret;
      };
      $scope.randomMarkers = [];
      // Get the bounds from the map once it's loaded
      $scope.$watch(function() {
        return $scope.map.bounds;
      }, function(nv, ov) {
        // Only need to regenerate once
        if (!ov.southwest &amp;&amp; nv.southwest) {
          var markers = [];
          for (var i = 0; i &lt; 2; i++) {
            markers.push(createRandomMarker(i, $scope.map.bounds))
          }
          $scope.randomMarkers = markers;
        }
      }, true);
    });
  </code></pre>