-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelax_Care_Map_JS
More file actions
135 lines (111 loc) · 3.19 KB
/
relax_Care_Map_JS
File metadata and controls
135 lines (111 loc) · 3.19 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
var temp_lat = '';
var temp_lng = '';
var map;
var infowindow;
getLocation();
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
temp_lat = 0.0; //set default lat value
temp_lng = 0.0; //set default lng value
}
}
function showPosition(position) {
temp_lat = position.coords.latitude;
temp_lng = position.coords.longitude;
initMap();
}
function initMap() {
var pyrmont = {
lat: temp_lat,
lng: temp_lng
};
map = new google.maps.Map(document.getElementById('map'), {
center: pyrmont,
zoom: 15
});
infowindow = new google.maps.InfoWindow();
var iconBase = 'https://maps.google.com/mapfiles/kml/shapes/';
var icons = {
parking: {
icon: iconBase + 'parking_lot_maps.png'
},
library: {
icon: iconBase + 'library_maps.png'
},
info: {
icon: iconBase + 'info-i_maps.png'
}
};
var features = [{
position: new google.maps.LatLng(pyrmont),
type: 'info'
}];
features.forEach(function(feature) {
var marker = new google.maps.Marker({
position: feature.position,
icon: icons[feature.type].icon,
map: map
});
});
var service = new google.maps.places.PlacesService(map);
service.nearbySearch({
location: pyrmont,
radius: 1000,
type: ['lodging']
},
callback);
}
var places = [];
function callback(results, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
createMarker(results[i]);
document.getElementById('output').innerHTML = places[i] + "<br>" + document.getElementById('output').innerHTML;
}
}
}
function myFunction(loc) {
var str = location
var sln = str.length;
var latt = loc.indexOf("(");
var lngg = loc.indexOf(",");
var lat = loc.slice(latt + 1, latt + 7);
var lng = loc.slice(lngg + 2, lngg + 10);
var url = "http://google.com/maps?q=" + lat + "," + lng;
// http://maps.google.com/maps?q=24.197611,120.780512
window.url = url;
document.getElementById('output').innerHTML = loc.slice(0, latt) + "<button onclick=myFunction1(location)>Go here!</button>";
//+ str.slice(1,sln-1) ;
// var btn = document.createElement("BUTTON");
// document.getElementById('output').innerHTML=document.getElementById('output').innerHTML + btn;
alert(loc.slice(0, latt) + "\n\n To go to that location, click <Go here!>");
//window.open(url);
}
function myFunction1(loc) {
//var str = loc;
//var sln = str.length;
//var url = loc//"http://maps.google.com/" ;
window.open(url);
}
function createMarker(place) {
var placeLoc = place.geometry.location;
var marker = new google.maps.Marker({
map: map,
position: place.geometry.location
});
google.maps.event.addListener(marker, 'click',
function() {
infowindow.setContent(place.name + placeLoc);
var location = place.name + placeLoc;
//var lng1 = place.lng;
infowindow.open(map, this);
myFunction(location);
}
);
places.push(place.name + "<br>" + placeLoc + "<br>"); // + " <button onclick=myFunction(location)>Go here!</button>");
//alert(places);
//alert(places.length)
}
marker1.setMap(map);