You need to sign in to do that
Don't have an account?
B
get current latitude and longitude javascript function ?
I have the map
var lat, lng
var map = component.get('v.map');
map.locate({setView: true, maxZoom: 13});
function onLocationFound(e) {
lat = e.latlng.lat
lng = e.latlng.lng
}
I need specifficaly lat lng from my current position
var lat, lng
var map = component.get('v.map');
map.locate({setView: true, maxZoom: 13});
function onLocationFound(e) {
lat = e.latlng.lat
lng = e.latlng.lng
}
I need specifficaly lat lng from my current position
All Answers
startPos = position; -- this is shown as undefinied
//3.Setting Lat in component.
component.set('v.startLat',startPos.coords.latitude);
//4.Setting Long in component.
component.set('v.startLng',startPos.coords.longitude);
};
alert(component.get('v.startLat')); - null
The component declaration of Lng and Lat
<aura:attribute name="startLng" type="Double"/>
<aura:attribute name="startLat" type="Double"/>
I just need lat and long for using them somewhere else
Any ideas ?
map.locate({setView: true, maxZoom: 13});
function onLocationFound(e) {
L.marker(e.latlng,{icon:pin_green}).addTo(map)
.bindPopup("You are here").openPopup();
component.set('v.startLat',e.latitude);
component.set('v.startLng',e.longitude);
}
And i set it in the function where the map is loaded beacuse i tried to get lat and long it in second function and it just cant be done like that
Thanks for help