Go Back   CodingForums.com > :: Client side development > General web building

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-13-2013, 02:12 PM   PM User | #1
needsomehelp
Regular Coder

 
Join Date: Oct 2009
Posts: 307
Thanks: 4
Thanked 3 Times in 3 Posts
needsomehelp can only hope to improve
Mobile GPS

I am trying to get a fix on mobile devices, of course if they agree to their location to be given out.

Just like some websites ask if my pc's location can be given out. But when I allow my pc's location it always shows a location in London, being my ISP, which must mean that the location is got using my IP address.

Can anyone suggest how I can go about getting the exact or near exact location of mobile devices that connect to my site. Would it be using PHP and HTML or Javascript ? I have no idea where to start.
needsomehelp is offline   Reply With Quote
Old 03-20-2013, 01:45 AM   PM User | #2
patryk
Regular Coder

 
patryk's Avatar
 
Join Date: Oct 2012
Location: /dev/couch
Posts: 395
Thanks: 2
Thanked 64 Times in 64 Posts
patryk is on a distinguished road
javascript.
check out this doc: http://dev.w3.org/geo/api/spec-source.html
and here's nice demo with sources on github: http://html5demos.com/geo

location is accessed via javascript obviusly. and then you do whatever you want with it

basically it's
Code:
<script language="javascript">
function successCallback(data){
	document.writeln('accuracy: ' + data.coords.accuracy + '<br />');
	document.writeln('altitude: ' + data.coords.altitude + '<br />');
	document.writeln('altitude accuracy: ' + data.coords.altitudeAccuracy + '<br />');
	document.writeln('heading: ' + data.coords.heading + '<br />');
	document.writeln('latitude: ' + data.coords.latitude + '<br />');
	document.writeln('longitude: ' + data.coords.longitude + '<br />');
	document.writeln('speed: ' + data.coords.speed + '<br />');
	document.writeln('timestamp: ' + data.timestamp);
}

function errorCallback(data){
	document.writeln('error');
}

if(navigator.geolocation){
	navigator.geolocation.getCurrentPosition(successCallback, errorCallback);
}else{
	document.writeln('not supported');
}
</script>
yes it's that simple. paste it INSIDE document's body and open

Last edited by patryk; 03-20-2013 at 02:08 AM..
patryk is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:08 AM.


Advertisement
Log in to turn off these ads.