72 lines
2.3 KiB
HTML
72 lines
2.3 KiB
HTML
<!DOCTYPE html>
|
|
<html ng-app="myapp">
|
|
<head>
|
|
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
|
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
|
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script>
|
|
<script src="scripts/app.js"></script>
|
|
<!-- build:js scripts/ng-map.min.js -->
|
|
<script src="../app/scripts/app.js"></script>
|
|
<script src="../app/scripts/directives/map_controller.js"></script>
|
|
<script src="../app/scripts/directives/map.js"></script>
|
|
<script src="../app/scripts/directives/marker.js"></script>
|
|
<script src="../app/scripts/directives/shape.js"></script>
|
|
<script src="../app/scripts/services/geo_coder.js"></script>
|
|
<script src="../app/scripts/services/navigator_geolocation.js"></script>
|
|
<script src="../app/scripts/services/attr2_options.js"></script>
|
|
<!-- endbuild -->
|
|
<script>
|
|
var app = angular.module('myapp', ['ngMap']);
|
|
app.controller('PolygonArraysCtrl', function($scope) {
|
|
var infoWindow = new google.maps.InfoWindow();
|
|
$scope.showArrays = function(event) {
|
|
|
|
// Since this polygon has only one path, we can call getPath()
|
|
// to return the MVCArray of LatLngs.
|
|
var vertices = this.getPath();
|
|
|
|
var contentString = '<b>Bermuda Triangle polygon</b><br>' +
|
|
'Clicked location: <br>' + event.latLng.lat() + ',' + event.latLng.lng() +
|
|
'<br>';
|
|
|
|
// Iterate over the vertices.
|
|
for (var i =0; i < vertices.getLength(); i++) {
|
|
var xy = vertices.getAt(i);
|
|
contentString += '<br>' + 'Coordinate ' + i + ':<br>' + xy.lat() + ',' +
|
|
xy.lng();
|
|
}
|
|
|
|
// Replace the info window's content and position.
|
|
infoWindow.setContent(contentString);
|
|
infoWindow.setPosition(event.latLng);
|
|
|
|
infoWindow.open($scope.map);
|
|
}
|
|
});
|
|
</script>
|
|
</head>
|
|
|
|
<body>
|
|
<div ng-controller="PolygonArraysCtrl">
|
|
<map zoom="5"
|
|
center="24.886436490787712, -70.2685546875"
|
|
map-type-id="TERRAIN">
|
|
<shape name="polygon"
|
|
on-click="showArrays()"
|
|
paths="[
|
|
[25.774252, -80.190262],
|
|
[18.466465, -66.118292],
|
|
[32.321384, -64.75737]
|
|
]"
|
|
stroke-color="#FF0000"
|
|
stroke-opacity="0.8"
|
|
stroke-weight="2"
|
|
fill-color="#FF0000"
|
|
fill-opacity="0.35">
|
|
</shape>
|
|
</map>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|