Web Programming examples

Google Maps,AngularJS

Google Maps for AngularJS Fusion Table(v2.4.1)

  • AngularJS : 1.6.5
  • Google Maps for AngularJS : 2.4.1
  • include file
  • angular.min.js, lodash.underscore.min.js, angular-simple-logger.min.js,angular-google-maps.min.js
<div ng-controller="MyCtrl">
  <div class="row">
    <div class="col-sm-12">
    <ui-gmap-google-map 
      id="map-canvas"
      center="map.center"
      zoom="map.zoom"
      draggable="true"
      options="map.options"
      events="map.events"
    >
      <ui-gmap-layer type="FusionTablesLayer" show="map.fusionlayer.showFusionTables" options="map.fusionlayer.options"></layer>
    </ui-gmap-google-map>
    </div>
  </div>
</div>
var mapApp = angular.module('googleMapApp', ['uiGmapgoogle-maps']);

mapApp.config(
    ['uiGmapGoogleMapApiProvider', function(GoogleMapApiProviders) {
        GoogleMapApiProviders.configure({
          key: 'your Google Map api key',
          v: '3', //defaults to latest 3.X anyhow
          libraries: 'weather,geometry,visualization'
        });
    }]
);

mapApp.controller("MyCtrl",['$scope', 'uiGmapGoogleMapApi', function ($scope,uiGmapGoogleMapApi) {
  angular.extend($scope, {
    map: {
      center: {
        latitude: 35.681382,
        longitude: 139.766084
      },
      options: {
        maxZoom: 20,
        minZoom: 3
      },
      zoom: 15,
      fusionlayer: {
        showFusionTables: true,
        options: {
          query: {
            select: '\'Location\'',
            from: '1Gz..............'
          },
          styles: [{
            markerOptions: {
              iconName: "large_green"
            }
          }, {
            where: "type = '公園'",
            markerOptions: {
              iconName: "parks"
            }
          }, {
            where: "type = 'サイクリング'",
            markerOptions: {
              iconName: "cycling"
            }
          }]
        }
      }
    }
  });
  uiGmapGoogleMapApi.then(function(maps) {});
}]);

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.