- 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"
dragging="map.dragging"
options="map.options"
>
<ui-gmap-polyline ng-repeat="p in map.polylines"
path="p.path"
stroke="p.stroke"
visible='p.visible'
geodesic='p.geodesic'
fit="false"
editable="p.editable"
draggable="p.draggable">
</ui-gmap-polyline>
</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,places'
});
}]
);
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,
polylines: [
{
path: [
{
latitude: 35.67941788049046,
longitude: 139.75768089294434
},
{
latitude: 35.67793632362604,
longitude: 139.76341009140015
},
{
latitude: 35.680759972963095,
longitude: 139.76446151733398
},
{
latitude: 35.68130028953324,
longitude: 139.76555585861206
}
],
stroke: {
color: '#6060FB',
weight: 4
},
editable: true,
draggable: false,
geodesic: false,
visible: true
},
{
path: [
{
latitude: 35.682572633455436,
longitude: 139.77615594863892
},
{
latitude: 35.681579161170134,
longitude: 139.77576971054077
},
{
latitude: 35.682502916505676,
longitude: 139.77373123168945
},
{
latitude: 35.67920872118891,
longitude: 139.77173566818237
}
],
stroke: {
color: '#6060FB',
weight: 3
},
editable: true,
draggable: true,
geodesic: true,
visible: true
}
]
}
});
uiGmapGoogleMapApi.then(function(maps) {});
}]);