Solved

get gps location from smartphone

Posted on 2011-02-28
22
1,612 Views
Last Modified: 2012-05-11
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
Comment
Question by:T1Tower
  • 11
  • 6
  • 2
  • +1
22 Comments
 
LVL 25

Expert Comment

by:RobMobility
ID: 35004563
Hi,

Perhaps this will help:

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

Regards,



RobMobility
0
 
LVL 25

Expert Comment

by:RobMobility
ID: 35004564
Hi,

Perhaps this will help:

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

Regards,



RobMobility
0
 

Author Comment

by:T1Tower
ID: 35009553
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
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 35026457
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
 
LVL 37

Expert Comment

by:CyanBlue
ID: 35026513
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
 

Author Comment

by:T1Tower
ID: 35031209
Thank you Alexey and CyanBlue

Let me check google maps code.

0
 

Author Comment

by:T1Tower
ID: 35031298
BTW, someone know how to edit the question text ?
Time ago it was so easy!.
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 35031342
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
 

Author Comment

by:T1Tower
ID: 35059637
thanks

Still running tests
0
 

Author Comment

by:T1Tower
ID: 35087066
Still running tests, its a lot of material that I have to check.

A small code sample would have been good.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 37

Expert Comment

by:CyanBlue
ID: 35087141
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
 

Author Comment

by:T1Tower
ID: 35087239
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
 
LVL 37

Accepted Solution

by:
CyanBlue earned 500 total points
ID: 35099518
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
 

Author Comment

by:T1Tower
ID: 35174470
so far the tests worked, checking implementation.
0
 

Author Comment

by:T1Tower
ID: 35176491
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
 

Author Comment

by:T1Tower
ID: 35176494
GOT IT.
0
 

Author Closing Comment

by:T1Tower
ID: 35176505
Thank you CyanBlue
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 35177356
Glad to hear that you've got it working...  ;)

CyanBlue
0
 

Author Comment

by:T1Tower
ID: 35182641
Thank you.

Thank you all for your valuable input.
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 35182683
No problem...  :)

CyanBlue
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now