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: hamishwillee (07 Feb 2012)

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);
}
}
}

Comments

Reviewer-approved.png
27 Sep
2009
Article Review by kalki (20090927)

This articles gives an innovative solution to most common requirement of today's youngsters. The main problem explained here is how can we show particular location dynamically to others on remote location. It gives example of railway station on which friends from outside the station coming to our home and if we want to show our home's exact dynamic location map to them on their device this article shows complete example.


This article can become next innovative application in LBS category. Must try an example. given code example runs perfectly.Advantage of using this code and idea of this application is so innovative.

This page was last modified on 7 February 2012, at 06:27.
73 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 2012 All rights reserved