-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoogleAPIv3_Final.html
224 lines (172 loc) · 9.87 KB
/
GoogleAPIv3_Final.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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="Chirag Vora" content="width=device-width, initial-scale=1.0" />
<title>Google Map Cutomization !!</title>
<!-- Setup jQuery : Why ? to speed development up -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<!-- Setup Google Map APIv3 : for Usage Report pls visit "http://goo.gl/ZswNva"-->
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&sensor=false&key=AIzaSyD9JpEVeKmDRLnxJnR8HPIdFRJcR8LoP7U"></script>
<!-- API key can be obtained from Google APIs Console -->
<script type="text/javascript">
var map;
//to locate ahemadabad border. so many points are used to determinie accurate border.
var newarkcoords = [{ Longitude: "72.480927", Latitude: "23.019708" }, { Longitude: "72.480240", Latitude: "23.029187" }, { Longitude: "72.482986", Latitude: "23.039930" }, { Longitude: "72.490540", Latitude: "23.068361" }, { Longitude: "72.492599", Latitude: "23.080995" }, { Longitude: "72.498093", Latitude: "23.093628" }, { Longitude: "72.504272", Latitude: "23.108786" }, { Longitude: "72.515945", Latitude: "23.124574" }, { Longitude: "72.523499", Latitude: "23.130257" }, { Longitude: "72.534485", Latitude: "23.132152" }, { Longitude: "72.544785", Latitude: "23.131520" }, { Longitude: "72.561264", Latitude: "23.131520" }, { Longitude: "72.575684", Latitude: "23.128994" }, { Longitude: "72.587357", Latitude: "23.129626" }, { Longitude: "72.594223", Latitude: "23.124574" }, { Longitude: "72.603149", Latitude: "23.120785" }, { Longitude: "72.610016", Latitude: "23.117628" }, { Longitude: "72.620316", Latitude: "23.115102" }, { Longitude: "72.630615", Latitude: "23.113207" }, { Longitude: "72.640228", Latitude: "23.111312" }, { Longitude: "72.649841", Latitude: "23.110681" }, { Longitude: "72.659454", Latitude: "23.111944" }, { Longitude: "72.669754", Latitude: "23.113207" }, { Longitude: "72.675934", Latitude: "23.106260" }, { Longitude: "72.684860", Latitude: "23.104365" }, { Longitude: "72.688293", Latitude: "23.094891" }, { Longitude: "72.690353", Latitude: "23.086048" }, { Longitude: "72.689667", Latitude: "23.074678" },{ Longitude: "72.691040", Latitude: "23.065202" }, { Longitude: "72.690353", Latitude: "23.058884" }, { Longitude: "72.685547", Latitude: "23.048776" }, { Longitude: "72.680054", Latitude: "23.042457" }, { Longitude: "72.676620", Latitude: "23.035506" }, { Longitude: "72.673874", Latitude: "23.021604" }, { Longitude: "72.673187", Latitude: "23.013388" }, { Longitude: "72.671814", Latitude: "23.006436" }, { Longitude: "72.662888", Latitude: "22.979888" }, { Longitude: "72.662888", Latitude: "22.974199" }, { Longitude: "72.664261", Latitude: "22.972302" }, { Longitude: "72.661514", Latitude: "22.968509" }, { Longitude: "72.658768", Latitude: "22.962187" }, { Longitude: "72.654648", Latitude: "22.952703" }, { Longitude: "72.649841", Latitude: "22.946380" }, { Longitude: "72.645035", Latitude: "22.943218" }, { Longitude: "72.638855", Latitude: "22.939424" }, { Longitude: "72.630615", Latitude: "22.935630" }, { Longitude: "72.623062", Latitude: "22.934365" }, { Longitude: "72.616882", Latitude: "22.931836" }, { Longitude: "72.612076", Latitude: "22.929306" }, { Longitude: "72.605209", Latitude: "22.930571" }, { Longitude: "72.599716", Latitude: "22.928042" }, { Longitude: "72.588730", Latitude: "22.928042" }, { Longitude: "72.580490", Latitude: "22.924880" }, { Longitude: "72.570877", Latitude: "22.924247" }, { Longitude: "72.555084", Latitude: "22.921718" }, { Longitude: "72.543411", Latitude: "22.924880" }, { Longitude: "72.537918", Latitude: "22.930571" }, { Longitude: "72.524185", Latitude: "22.930571" }, { Longitude: "72.514572", Latitude: "22.933733" }, { Longitude: "72.504272", Latitude: "22.934998" }, { Longitude: "72.492599", Latitude: "22.936895" }, { Longitude: "72.486420", Latitude: "22.943851" }, { Longitude: "72.479553", Latitude: "22.952071" }, { Longitude: "72.475433", Latitude: "22.962187" }, { Longitude: "72.472687", Latitude: "22.976095" }, { Longitude: "72.473373", Latitude: "22.985578" }, { Longitude: "72.474747", Latitude: "22.995691" }, { Longitude: "72.475433", Latitude: "23.002644" }, { Longitude: "72.478867", Latitude: "23.012756" }, { Longitude: "72.480240", Latitude: "23.021604" }, { Longitude: "72.479553", Latitude: "23.032979" }, { Longitude: "72.480927", Latitude: "23.019708" } ];
//jQuery function loded once doc is ready
$(document).ready(function () {
var markers = [];
// Create object (LatLng) that contains coordinate for Ahmedabad
var latlng = new google.maps.LatLng(23.022505, 72.571362);
//Create literal object to initlize properties
var myOptions = {
zoom: 8, // initial zoom level
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP // it may be of ROADMAP/SATELLITE/HYBRID/TERRAIN
};
// initilize the map by calling the constructor
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
// Create the search box and link it to the UI element.
var input = (document.getElementById('pac-input'));
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
var searchBox = new google.maps.places.SearchBox((input));
// Listen for the event fired when the user selects an item from the
// pick list. Retrieve the matching places for that item.
google.maps.event.addListener(searchBox, 'places_changed', function() {
var places = searchBox.getPlaces();
if (places.length == 0) {
return;
}
for (var i = 0, marker; marker = markers[i]; i++) {
marker.setMap(null);
}
// For each place, get the icon, place name, and location.
markers = [];
var bounds = new google.maps.LatLngBounds();
for (var i = 0, place; place = places[i]; i++) {
var image = {
url: place.icon,
size: new google.maps.Size(71, 71),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(17, 34),
scaledSize: new google.maps.Size(25, 25)
};
// Create a marker for each place.
var marker = new google.maps.Marker({
map: map,
icon: image,
title: place.name,
position: place.geometry.location
});
markers.push(marker);
bounds.extend(place.geometry.location);
}
map.fitBounds(bounds);
});
// move user's view point towards new serched location
google.maps.event.addListener(map, 'bounds_changed', function() {
var bounds = map.getBounds();
searchBox.setBounds(bounds);
});
var NewarkHighlight;
var mNewarkCoords = new Array;
for (var i = 0; i < newarkcoords.length; i++) {
mNewarkCoords[i] = new google.maps.LatLng(newarkcoords[i].Latitude, newarkcoords[i].Longitude);
}
// Creating border using Polygon
NewarkHighlight = new google.maps.Polygon({
paths: mNewarkCoords,
strokeColor: "#FF0000",
strokeOpacity: 1,
strokeWeight: 3,
fillColor: "#428bca",
fillOpacity: 0.35
});
google.maps.event.addListener(map, 'click', function(e) {
var result;
if (google.maps.geometry.poly.containsLocation(e.latLng, NewarkHighlight)) {
result = 'green';
} else {
result = 'red';
NewarkHighlight.setMap(map);
}
var circle = {
path: google.maps.SymbolPath.CIRCLE,
fillColor: result,
fillOpacity: 3,
strokeColor: 'blue',
strokeWeight: .5,
scale: 5
};
new google.maps.Marker({
position: e.latLng,
map: map,
icon: circle
})
});
});
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<style type="text/css">
html,body { height: 100%; margin: 0px; padding: 0px; }
#map_canvas {
width:90%;
height:90%;
margin: 60px;
margin-top: 5px;
}
#ui {
font-size: 16px;
font-family: Verdana, sans-serif;
color: #4d90fe ;
text-align: center;
}
.controls {
margin-top: 16px;
border: 1px solid transparent;
border-radius: 2px 0 0 2px;
box-sizing: border-box;
-moz-box-sizing: border-box;
height: 32px;
outline: none;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
#pac-input {
background-color: #fff;
padding: 0 11px 0 13px;
width: 400px;
font-family: Roboto;
font-size: 15px;
font-weight: 300;
text-overflow: ellipsis;
text-align: center;
}
#pac-input:focus {
border-color: #4d90fe;
margin-left: -1px;
padding-left: 14px;
width: 401px;
}
.pac-container {
font-family: Roboto;
}
#type-selector {
color: #fff;
background-color: #4d90fe;
padding: 5px 11px 0px 11px;
}
#type-selector label {
font-family: Roboto;
font-size: 13px;
font-weight: 300;
}
</style>
</head>
<body >
<input id="pac-input" class="controls" type="text" placeholder="Which Place You are Looking for !!">
<div id="ui">by Chirag Vora!!</div>
<div id="map_canvas"></div>
</div>
</body>
</html>