Solved

get gps location from smartphone

Posted on 2011-02-28
22
1,629 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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
 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

777 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