-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsukeymap.js
116 lines (106 loc) · 2.77 KB
/
sukeymap.js
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*jsl:option explicit*/
var defaultloc = new google.maps.LatLng(51.50348, -0.126901);
var currloc = null;
var map;
var me = null;
var followMe = true;
var marker;
function closeMap(){
var scr = document.getElementById('scr');
var dad=scr.parentNode;
if(dad){
dad.removeChild(scr);
}
marker = null;
scr = document.createElement("div");
scr.setAttribute('id', 'scr');
scr.style.width= displayWidth + "px";
scr.style.height= displayHeight - 96 + "px";
scr.style.top= "96px";
scr.style.margin = "0 auto";
scr.style.position="relative";
scr.style.textAlign = "center";
my_div = document.getElementById("buttondiv");
scr = document.body.insertBefore(scr, my_div);
vote = document.createElement("div");
vote.setAttribute('id','votebuttondiv');
vote.style.bottom="10px";
vote.style.display="none";
vote.innerHTML= "<div style='float:right'><img src='reportsendbutton.png'></div><div style='float:right;padding:17px 0px;'> Give your opinion </div>";
vote.addEventListener("click", voteExit);
scr.appendChild(vote);
}
function initMap(divname) {
mode="map";
if (canUseNativeMap){
initNativeMap(divname);
} else {
initGoogleMap(divname);
}
}
function initNativeMap(divname){
document.location = 'openmap:london';
}
function initGoogleMap(divname){
if (clat){
currloc = new google.maps.LatLng(clat, clon);
defaultloc = currloc;
}
map = new google.maps.Map(
document.getElementById(divname), {
zoom: 16,
center: defaultloc,
mapTypeId: google.maps.MapTypeId.ROADMAP,
draggable: true
}
);
mapviewlayer = new google.maps.KmlLayer(
URLKML, {
map: map,
preserveViewport: true,
clickable: false
}
);
marker = new google.maps.Marker({
position: currloc,
map: map,
title:"You are here"
});
if (!canUseGeo){
marker.setDraggable(true);
google.maps.event.addListener(marker, 'dragend', function() {
moveMapPin();
});
}
}
function moveMapPin(){
defaultloc = marker.getPosition();
setNewFoneLocation(marker.getPosition().lat(), marker.getPosition().lng());
}
function locateError() {
if (currloc === null) {
currloc = defaultloc;
}
}
function locateSuccess(pos) {
if (currloc !== pos){
currloc = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude);
clat = pos.coords.latitude;
clon = pos.coords.longitude;
if (me === null) {
var bounds = new google.maps.LatLngBounds(defaultloc, defaultloc);
bounds.extend(currloc);
map.fitBounds(bounds);
me = new google.maps.Marker({
map: map,
draggable: false,
animation: google.maps.Animation.DROP,
position: currloc
});
}
if(followMe) {
map.setCenter(currloc);
followMe = false;
}
}
}