-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaps.js
More file actions
40 lines (36 loc) · 1.22 KB
/
maps.js
File metadata and controls
40 lines (36 loc) · 1.22 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
//Ubicacion del usuario
function initMap() {
var map = new google.maps.Map(document.getElementById('map-yo'), {
center: {lat: -10.6607781, lng: -76.2523706},
zoom: 15
});
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
};
infoWindow.setPosition(pos);
infoWindow.setContent('Aqui estas tú');
map.setCenter(pos);
}, function() {
handleLocationError(true, infoWindow, map.getCenter());
});
} else {
handleLocationError(false, infoWindow, map.getCenter());
}
function handleLocationError(browserHasGeolocation, infoWindow, pos) {
infoWindow.setPosition(pos);
infoWindow.setContent(browserHasGeolocation ?
'Error: La Geolocalizacion no esta disponible.' :
'Error: Tu navegador no soporta la Geolocalizacion.');
}
//Normal
var origin = {lat: -10.6607781, lng: -76.2523706};
var map = new google.maps.Map(document.getElementById('map-normal'), {
zoom: 5,
center: origin
});
google.maps.event.trigger(map, 'resize');
}