Monday, August 23, 2010

Gps in J2me,Blackberry

GPS(Global positioning system) can be achieved using Location API which is an optional package for J2ME.Blackberry also uses the same APi for GPS.Location APi(Jsr 179) is provided by nokia.

the code for getting the latitude and longitude is:
Criteria c=new Criteria();
c.setHorizontalAccuracy(1000);
c.setVerticalAccuracy(1000);
c.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
LocationProvider lp=LocationProvider.getInstance(c);
Location loc=lp.getLocation(60);
QualifiedCoordinates qc=loc.getQualifiedCoordinates();

Latitude can be retried by qc.getLatitude()
Longitude can be retrieved by qc.getLongitude()

these latitude and longitude can be then provided to google static maps to get relevant maps.
some google urls are
http://maps.google.com/maps/api/staticmap?zoom=14&size=200x200&maptype=roadmap&markers=color:red|label:S|40.714728,-73.998672&sensor=false
The above url will give a static map with pointing marker.

No comments:

Post a Comment