-
Notifications
You must be signed in to change notification settings - Fork 5
/
GoogleMapsAPIExample-Sam.html
39 lines (33 loc) · 1.04 KB
/
GoogleMapsAPIExample-Sam.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
<!--this is a copy of an html file to add a map with your current location -->
<script src="https://maps.googleapis.com/maps/api/js?key=<%= @api_key %>&callback=initMap&libraries=places" async defer>
</script>
<script>
var dbc = {lat: 37.7846334, lng: -122.3996024};
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: dbc,
zoom: 6
});
// var marker = new google.maps.Marker({
// position: {lat: 37.63653, lng: -121.82376},
// map: map
// })
var infoWindow = new google.maps.InfoWindow({map: map});
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
// var marker = new google.maps.Marker({
// position: pos,
// map: map
// })
var content = '<a>Example Text</a>'
infoWindow.setPosition(pos);
infoWindow.setContent(content);
map.setCenter(pos);
});
};
}
</script>