Namespaces
Variants
Actions

Make your own map

Jump to: navigation, search
Article Metadata

Tested with
Devices(s): 2710N

Compatibility
Platform(s): Since S60 3rd Edition, Since Series 40 6th Edition

Article
Keywords: javax.microedition.location.LocationProvider, javax.microedition.location.Location, javax.microedition.location.Coordinates.getLatitude, javax.microedition.location.Coordinates.getLongitude()
Created: vivartpandey (28 May 2008)
Reviewed: skalogir (06 Oct 2011)
Last edited: jasfox (25 Apr 2013)

Overview

This is a simple Midlet that can help you get and display on the phone's screen the coordinates on each of a route's critical turning points, as well as the direction (left or right) towards which you are heading. The idea is to be able to send this information to someone who needs directions when following the same route.

Example Code

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.location.*;
 
public class LBS extends MIDlet implements CommandListener {
//soft key indication for direction.
Command Right = new Command("RIGHT",Command.ITEM,0);
Command Left = new Command("LEFT",Command.BACK,0);
//first coordinate that is your starting point.
 
String direction="Starting point";
public LBS() {}
Form f=new Form("Waiting...");
public void startApp() {
 
f.append("Start");
f.addCommand(Left);
f.addCommand(Right);
f.setCommandListener(this);
Display.getDisplay(this).setCurrent(f);
 
getCoordinates(f,direction);
 
}
 
private void getCoordinates(Form f,String dir) {
try {
Criteria c=new Criteria();
c.setHorizontalAccuracy(100);
c.setVerticalAccuracy(100);
c.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
LocationProvider lp=LocationProvider.getInstance(c);
Location loc=lp.getLocation(60);
QualifiedCoordinates qc=loc.getQualifiedCoordinates();
f.append(dir);
f.append("Alt: "+qc.getAltitude());
f.append("Lat: "+qc.getLatitude());
f.append("Long: "+qc.getLongitude());
 
} catch(Exception e) {
f.append("Exception: "+e);
}
}
 
public void pauseApp() {}
 
public void destroyApp(boolean destroy) {}
 
public void commandAction(Command c, Displayable s) {
//whenever your press left this will show the cordinates
//of the turning point.with the label of left.
 
if (c == Left) {
 
direction="\nLEFT";
getCoordinates(f,direction);
}
//when ever you press the right this will show the coordinates of
// the turning point for the right.
 
if (c == Right) {
 
direction="\nRIGHT";
getCoordinates(f,direction);
}
}
}
This page was last modified on 25 April 2013, at 10:47.
199 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved