Web Programming examples

Google Maps,AngularJS

Google Maps for AngularJS markers-label(v1.2.1)

  • AngularJS : 1.2.23
  • Bootstrap : 3.2.0
  • Google Maps for AngularJS : 1.2.1
  • include file
  • angular.min.js, lodash.underscore.min.js, angular-google-maps.min.js, ui-bootstrap-tpls-0.11.0.min.js
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&key=xxxxxxxxxxxxxxxxxx&sensor=false"></script>
<script type='text/javascript' src='http://www.example.com/wp/wp-content/themes/ang/js/lodash.underscore.min.js'></script>
<script type='text/javascript' src='http://www.example.com/wp/wp-content/themes/ang/js/angular-google-maps.min.js'></script>
<script type='text/javascript' src='http://www.example.com/wp/wp-content/themes/ang/js/app.js'></script>
<div ng-controller="MyCtrl">
  <div class="row">
    <div class="col-sm-12">
      <google-map id="map-canvas" center="map.center" zoom="map.zoom" draggable="true" options="map.options">
        <markers models="map.markers" coords="'self'"
          options="'options'" icon="'icon'" isLabel='true' >
      </markers>
      </google-map>
    </div>
  </div>
</div>
var mapApp = angular.module('googleMapApp', ['google-maps','ui.bootstrap']);

mapApp.controller("MyCtrl", function ($scope) {

  angular.extend($scope, {
    map: {
      center: {
        latitude: 35.681382,
        longitude: 139.766084
      },
      options: {},
      zoom: 15,
      markers: [
        {
          latitude: 35.681382,
          longitude: 139.766084,
          icon: 'http://maps.google.co.jp/mapfiles/ms/icons/pink.png',
          id: 1,
          options: {
            labelContent: 1,
            labelAnchor: '4 30',
            labelClass: 'marker-labels1'
          },
        },
        {
          latitude: 35.682032,
          longitude: 139.762294,
          icon: 'http://maps.google.co.jp/mapfiles/ms/icons/pink.png',
          id: 2,
          options: {
            labelContent: 2,
            labelAnchor: '4 30',
            labelClass: 'marker-labels1'
          },
        },
        {
          latitude: 35.678354,
          longitude: 139.761028,
          icon: 'http://maps.google.co.jp/mapfiles/ms/icons/pink.png',
          id: 3,
          options: {
            labelContent: 3,
            labelAnchor: '4 30',
            labelClass: 'marker-labels1'
          },
        }
      ]
    }
  });
});