-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgooglemaps.html
66 lines (57 loc) · 1.8 KB
/
googlemaps.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<html>
<head>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map { height: 100% }
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var poly, map;
var markers = [];
var path = new google.maps.MVCArray;
function initialize() {
var uluru = new google.maps.LatLng(-25.344, 131.036);
map = new google.maps.Map(document.getElementById("map"), {
zoom: 14,
center: new google.maps.LatLng(24.886436490787712, -70.2685546875),
zoom: 2,
mapTypeId: google.maps.MapTypeId.SATELLITE
});
poly = new google.maps.Polygon({
strokeWeight: 3,
fillColor: '#5555FF'
});
poly.setMap(map);
poly.setPaths(new google.maps.MVCArray([path]));
google.maps.event.addListener(map, 'click', addPoint);
}
function addPoint(event) {
path.insertAt(path.length, event.latLng);
var marker = new google.maps.Marker({
position: event.latLng,
map: map,
draggable: true,
icon : 'http://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=' + markers.length + '%7cFF0000%7c000000&.png%3f'
});
markers.push(marker);
marker.setTitle("#" + path.length);
google.maps.event.addListener(marker, 'click', function() {
marker.setMap(null);
for (var i = 0, I = markers.length; i < I && markers[i] != marker; ++i);
markers.splice(i, 1);
path.removeAt(i);
}
);
google.maps.event.addListener(marker, 'dragend', function() {
for (var i = 0, I = markers.length; i < I && markers[i] != marker; ++i);
path.setAt(i, marker.getPosition());
}
);
}
</script>
</head>
<body style="margin:0px; padding:0px;" onload="initialize()">
<div id="map"></div>
</body>
</html>