EDIT
I was wondering how I can complete the href from my anchor tag with Javascript.
I have the following function which gives back my longitude and latitude.
function(obj){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(userPosition,errorPosition);
}else {
alert('Geolocation is not available');
}
function userPosition(position){
obj.setAttribute('href', 'http://maps.google.com/maps? daddr=~ITEM.STREET~,+~ITEM.CITY~&saddr=' + position.coords.latitude + ',' position.coords.longitude);
}
function errorPosition(error){
switch(error.code){
case eror.PERMISSION_DENIED:
alert('permission denied');
break;
}
}
}
Here I get the my current location his latitude and longitude as an alert.
But what I want to do is the following. At the moment I have this.
<a class=localization href="#" onclick="geo(this)">
<img src="images/localizationIcon.png" width=35 height=45 />
</a>
I want that when I click on the image. The longitude and latitude is filled in in my href.
Can somebody help me?
Kind regards.
Stef
Change
onclick="geo()"toonclick="geo(this)"Change
function geo()tofunction geo(obj)replace userPosition’s alert with:
You will have to adjust this to match Google maps format. I’m not sure what they want the address in, but I’m pretty sure you are specifying a street address in this case, not a lat/longitude combination..