• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1676
  • Last Modified:

get gps location from smartphone

HELLO SUPER EXPERTS

Im building a PHP web app that need to know the GPS position of the device using the app.
How can I access that?
I bought a blackberry 9300 so we can run tests on it.

Thanks in advance
0
T1Tower
Asked:
T1Tower
  • 11
  • 6
  • 2
  • +1
1 Solution
 
Rob KnightConsultantCommented:
Hi,

Perhaps this will help:

http://www.toniwestbrook.com/archives/126

Regards,



RobMobility
0
 
Rob KnightConsultantCommented:
Hi,

Perhaps this will help:

http://www.toniwestbrook.com/archives/126

Regards,



RobMobility
0
 
T1TowerAuthor Commented:
Thank you RobMobility

I am editing the question since I need this to work on most common gps enabled smartphones and tablets, not just in blackberry.

The link you provided is very usefull, and Maybe the solution, let me see how the question develops.

THANK YOU!.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
alexey_gusevCommented:
you might want to check google maps: http://code.google.com/apis/maps/documentation/javascript/basics.html#DetectingUserLocation

as far as I understand you need to get it on the web page, not as local application
0
 
CyanBlueCommented:
Basically that just is the way it is...  In the mobile world, you don't really have much common ground for each devices...  So, either it should be that you find one web browser that works on majority of the devices you will want to support which allows you to get the current location as well, and tell users to use that one specifically so that you can do what you need...  Or, you need to build your own application that you can distribute on multiple devices...

If latter is your choice, RobMobility suggested what needs to be done, and you just need to find the alternatives for other devices...

If you have luxury of time, you 'could' test to see if Google Maps JS API works for you...  I did test this on iPhone some time ago, and I believe it works...  So, just test this technique with majority of your target devices and see if it does the job for you...
   http://code.google.com/apis/maps/documentation/javascript/basics.html#DetectingUserLocation

CyanBlue
0
 
T1TowerAuthor Commented:
Thank you Alexey and CyanBlue

Let me check google maps code.

0
 
T1TowerAuthor Commented:
BTW, someone know how to edit the question text ?
Time ago it was so easy!.
0
 
CyanBlueCommented:
I don't know how to update the question of this topic...  Maybe it is less confusing if you just state it below...

CyanBlue
0
 
T1TowerAuthor Commented:
thanks

Still running tests
0
 
T1TowerAuthor Commented:
Still running tests, its a lot of material that I have to check.

A small code sample would have been good.
0
 
CyanBlueCommented:
You might want to define/narrow it down so that we know what environment you are going and what language you are using...  There are so many ideas scattered around in this topic and we probably won't be able to give you any code snippets...  Please be more specific...

CyanBlue
0
 
T1TowerAuthor Commented:
Hello CyanBlue

I have a PHP script that is part of a larger system.
We need to know the location of a GPS enabled device ( smartphone / tablet )
Obviously the browser will ask the visitor for access to that information, and the user will approve or deny it.
Running PHP/MySQL

The link you provided has been helpful, but its a lot of material that I need to check.
0
 
CyanBlueCommented:
Did you try & test this code from that Google page???
// Note that using Google Gears requires loading the Javascript
// at http://code.google.com/apis/gears/gears_init.js

var initialLocation;
var siberia = new google.maps.LatLng(60, 105);
var newyork = new google.maps.LatLng(40.69847032728747, -73.9514422416687);
var browserSupportFlag =  new Boolean();

function initialize() {
  var myOptions = {
    zoom: 6,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  
  // Try W3C Geolocation (Preferred)
  if(navigator.geolocation) {
    browserSupportFlag = true;
    navigator.geolocation.getCurrentPosition(function(position) {
      initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
      map.setCenter(initialLocation);
    }, function() {
      handleNoGeolocation(browserSupportFlag);
    });
  // Try Google Gears Geolocation
  } else if (google.gears) {
    browserSupportFlag = true;
    var geo = google.gears.factory.create('beta.geolocation');
    geo.getCurrentPosition(function(position) {
      initialLocation = new google.maps.LatLng(position.latitude,position.longitude);
      map.setCenter(initialLocation);
    }, function() {
      handleNoGeoLocation(browserSupportFlag);
    });
  // Browser doesn't support Geolocation
  } else {
    browserSupportFlag = false;
    handleNoGeolocation(browserSupportFlag);
  }
  
  function handleNoGeolocation(errorFlag) {
    if (errorFlag == true) {
      alert("Geolocation service failed.");
      initialLocation = newyork;
    } else {
      alert("Your browser doesn't support geolocation. We've placed you in Siberia.");
      initialLocation = siberia;
    }
    map.setCenter(initialLocation);
  }
}

Open in new window


CyanBlue
0
 
T1TowerAuthor Commented:
so far the tests worked, checking implementation.
0
 
T1TowerAuthor Commented:
in the code sample, it shows the position in the map.  I am trying to get the latitude and longitude so the system can use it.

0
 
T1TowerAuthor Commented:
GOT IT.
0
 
T1TowerAuthor Commented:
Thank you CyanBlue
0
 
CyanBlueCommented:
Glad to hear that you've got it working...  ;)

CyanBlue
0
 
T1TowerAuthor Commented:
Thank you.

Thank you all for your valuable input.
0
 
CyanBlueCommented:
No problem...  :)

CyanBlue
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 11
  • 6
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now