-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
añadir geolocalizacion por google #61
base: miguel-nasaRoverChallenge
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sería bueno hacer un refactor en profundidad, me gusta mucho la idea del fallback con localización por IP! ;-)
|
||
|
||
|
||
let posicion = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No necesitas esta variable global...
|
||
|
||
function geo_success(position) { | ||
posicion.latitud = parseFloat(position.coords.latitude.toFixed(4)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Podrías meter esta transformación parseFloat(position.coords.latitude.toFixed(4));
en una función.. para reutilizarla después
function geo_success(position) { | ||
posicion.latitud = parseFloat(position.coords.latitude.toFixed(4)); | ||
posicion.longitud = parseFloat(position.coords.longitude.toFixed(4)); | ||
initMap(posicion.latitud,posicion.longitud); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No te hace falta poSicion
si ya tienes posiTion
initMap(posicion.latitud,posicion.longitud); | ||
} | ||
|
||
function geo_error() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esto parece un poco poltergeist
|
||
//probando la geolocalizacion | ||
function searchMe(){ | ||
navigator.geolocation.getCurrentPosition(geo_success, geo_error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
geo_error
no hace más que ejecutar... altSearch
, pásalo directamente ;-)
let marker; | ||
|
||
function initMap(long,lat) { | ||
map = new google.maps.Map(map, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mala idea reutilziar una variable map
que era un selector para que luego sea otro objeto. 😢
|
||
function initMap(long,lat) { | ||
map = new google.maps.Map(map, { | ||
center: {lat: long, lng: lat}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cómo es que lat
es long
???
Nota: con es6 puedes dejarlo en center: {lat, lng},
map = new google.maps.Map(map, { | ||
center: {lat: long, lng: lat}, | ||
zoom: 14, | ||
styles:[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Este array podría estar expuesto en otro fichero como style_maps.js
o similar...
<div style="height: 600px" id="map"></div> | ||
|
||
</div> | ||
<script src="whereIAm.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tu script siempre va al final de las dependencias..
|
||
</div> | ||
<script src="whereIAm.js"></script> | ||
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB0AeWwQW28gYeltyIMsTRYGh-Zu3YEYLQ&callback=searchMe" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
necesitabamos bootstrap?
Geolocalizacion con google (quiera o no el usuario)