Solved

get gps location from smartphone

Posted on 2011-02-28
22
1,645 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
You should read OS supplied guidelines before developing. I can't stress that enough. The guidelines will help you understand the reasons mobile app developers do what they do.  Apple is very particular when they review appstore submissions.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

632 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