<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&key=xxxxxxxxxxxxxxxxxx&sensor=false&libraries=places"></script>
<script type='text/javascript' src='http://www.example.com/wp/wp-content/themes/ang/js/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"
dragging="map.dragging"
options="map.options"
>
<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">
</polyline>
</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: {
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
}
]
}
});
});
Hello,
can you help me and explain how I can set the latidute and longitude values programatically after reading from a database?
$http.get(‘/home/GetAllCyclingCoordinates’).then(function (data) {
$scope.cyclingRouteCoords.push({
id: data.data.LocationID,
coords: ??? Loop ???
stroke: {color: ‘#ff0000’, weight: 2}
});
}, function() {
alert(‘GetAllCyclingCoordinatesError’);
//});