-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdealers.html
78 lines (71 loc) · 2.11 KB
/
dealers.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
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html>
<head>
<title>Dealers</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&key=AIzaSyA6sMUz_NgFMol5W2OehIUj0gP7rn8uvWM"></script>
<div id="map"></div>
<script>
var map;
var infowindow;
function initialize() {
var pyrmont = new google.maps.LatLng(19.0645548, 72.835844); // sample location to start with: Mumbai, India
map = new google.maps.Map(document.getElementById('map'), {
center: pyrmont,
zoom: 17
});
var marker = new google.maps.Marker({
map: map,
position: pyrmont,
icon:'http://maps.google.com/mapfiles/ms/icons/green-dot.png'
});
var request = {
location: pyrmont,
radius: 1000,
types: ['car_dealer'] // this is where you set the map to get the hospitals and health related places
};
infowindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, callback);
var trafficLayer = new google.maps.TrafficLayer();
trafficLayer.setMap(map);
}
function callback(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
createMarker(results[i]);
}
}
}
function createMarker(place) {
var placeLoc = place.geometry.location;
var marker = new google.maps.Marker({
map: map,
position: place.geometry.location
});
function info() {
infowindow.setContent(place.name);
infowindow.open(map, this);
}
google.maps.event.addListener(marker, 'click',info );
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</body>
</html>