com.nutiteq
Class MapItem

java.lang.Object
  extended by javax.microedition.lcdui.Item
      extended by javax.microedition.lcdui.CustomItem
          extended by com.nutiteq.MapItem
All Implemented Interfaces:
MapListener

public class MapItem
extends javax.microedition.lcdui.CustomItem
implements MapListener

A high level wrapper around MapComponent, to be used inside Forms.


Field Summary
 
Fields inherited from class javax.microedition.lcdui.Item
BUTTON, HYPERLINK, LAYOUT_2, LAYOUT_BOTTOM, LAYOUT_CENTER, LAYOUT_DEFAULT, LAYOUT_EXPAND, LAYOUT_LEFT, LAYOUT_NEWLINE_AFTER, LAYOUT_NEWLINE_BEFORE, LAYOUT_RIGHT, LAYOUT_SHRINK, LAYOUT_TOP, LAYOUT_VCENTER, LAYOUT_VEXPAND, LAYOUT_VSHRINK, PLAIN
 
Constructor Summary
MapItem(java.lang.String label, java.lang.String licenseKey, javax.microedition.midlet.MIDlet midlet, int width, int height, WgsPoint startPoint, int zoom)
          Constructor for map component wrapper, that can be used in high level UI components.
MapItem(java.lang.String label, java.lang.String licenseKey, java.lang.String vendor, java.lang.String appname, int width, int height, WgsPoint startPoint, int zoom)
          Constructor for map component wrapper, that can be used in high level UI components.
 
Method Summary
 void addKmlService(KmlService service)
          Add KML layer to the map Usage example: mapItem.addKmlService(new KmlUrlReader("http://www.panoramio.com/panoramio.kml?
 void addLine(Line line)
          Add single line to map
 void addLines(Line[] lines)
          Add multiple lines to map
 void addOnMapElements(OnMapElement[] elements)
          Add elements to be displayed on map
 void addPlace(Place place)
          Add Place to map
 void addPlaces(Place[] places)
          Add many places to map
 void addPolygon(Polygon polygon)
           
 void addPolygons(Polygon[] polygons)
           
 void defineControlKey(int keyCode, int keyValue)
          Define Control Keys codes for map manipulation.
 void enableDownloadCounter()
          Enable network traffic counter using default implementation ( NutiteqDownloadCounter).
 void enableDownloadDisplay()
          Enable network traffic overlay using default implementation for painting ( NutiteqDownloadDisplay).
 void enqueueDownload(ResourceRequestor downloadable, int cacheLevel)
          Enqueue new download task to be executed by library.
 PlaceInfo getAdditionalInfo(Place place)
          Get additional info for internally handled (retrieved from kml service) objects.
 WgsBoundingBox getBoundingBox()
          Get Bounding Box of current map view
 DownloadCounter getDownloadCounter()
           
 KmlService[] getKmlServices()
          List currently added KML Services
 java.lang.String getLibraryLog()
          Get internal log for library.
 GeoMap getMap()
          Retrieve currently used map.
 WgsPoint getMiddlePoint()
          Get current center point of map
 int getZoom()
          Get the current zoom level.
 ZoomRange getZoomRange()
          get max and min zoom of current map (typically 0...18)
 void mapClicked(WgsPoint p)
          Event for clicking on map (used in MapListener)
 void mapMoved()
          Event for moving of map (used in MapListener)
 void needRepaint(boolean mapIsComplete)
          Event if map needs repainting (used in MapListener)
 void removeKmlService(KmlService service)
          Remove previously added kml service
 void removeLine(Line line)
          Remove previously added line
 void removeLines(Line[] lines)
          Remove multiple lines
 void removeLocationSource()
          Remove used location source
 void removeOnMapElements(OnMapElement[] elements)
          Remove given elements from map display
 void removePlace(Place place)
          Remove Place from map
 void removePlaces(Place[] places)
          remove several places from map
 void removePolygon(Polygon polygon)
           
 void removePolygons(Polygon[] polygons)
           
 void setBoundingBox(WgsBoundingBox bBox)
          Set bounding box for the view.
 void setControlKeysHandler(ControlKeysHandler keysHandler)
          Change control keys handler used for actions mapping.
 void setCursor(Cursor newCursor)
          Replace the default cursor.
 void setDownloadCounter(DownloadCounter downloadCounter)
          Set download counter used for gathering information about network traffic
 void setDownloadDisplay(DownloadDisplay display)
          Set used implementation for network traffic display on map.
 void setDownloadStreamOpener(DownloadStreamOpener opener)
          Set download stream opener, that creates connections to downloaded resources
 void setErrorListener(ErrorListener eL)
          Set listener for component error events (connection errors, license errors, parsing errors etc
 void setFileSystem(FileSystem fs)
           
 void setLocationSource(LocationSource marker)
          Set location source with GPS marker to be displayed on map
 void setMap(GeoMap newMap)
          Change base map
 void setMapListener(MapListener mL)
          Set map listener for receiving callback events from library.
 void setMiddlePoint(double lon, double lat, int zoom)
          Set Center point of map
 void setMiddlePoint(WgsPoint wgs, int zoom)
          Set middle point of map
 void setNetworkCache(Cache cache)
          Set cache for networking.
 void setOnMapElementListener(OnMapElementListener listener)
           
 void setOnScreenZoomControls(OnScreenZoomControls controls)
          Set zoom controls to be displayed on screen and used for touch screen zooming.
 void setPanningStrategy(PanningStrategy panningStrategy)
          Set panning strategy for map component.
 void setPlaceListener(PlaceListener pL)
          Set Place listener to receive place "mouseover" and selection events
 void setZoom(int newZoom)
          Set map zoom without changing position.
 void setZoomLevelIndicator(ZoomIndicator zoomIndicator)
          Set zoom indicator to be painted on display
 void setTileSearchStrategy(GeoMap[] tileSearchStrategy)
          Set search strategy for map tile.
 void showZoomLevelIndicator(boolean showInicator)
          Show map zoom scale after zoom action.
 void startMapping()
          Initialize needed resources for mapping and start internal threads.
 void stopMapping()
          Stop threads started by MapComponent.
 void zoomIn()
          Zoom in map 1 step
 void zoomOut()
          Zoom out map 1 step
 
Methods inherited from class javax.microedition.lcdui.CustomItem
getGameAction
 
Methods inherited from class javax.microedition.lcdui.Item
addCommand, getLabel, getLayout, getMinimumHeight, getMinimumWidth, getPreferredHeight, getPreferredWidth, notifyStateChanged, removeCommand, setDefaultCommand, setItemCommandListener, setLabel, setLayout, setPreferredSize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapItem

public MapItem(java.lang.String label,
               java.lang.String licenseKey,
               javax.microedition.midlet.MIDlet midlet,
               int width,
               int height,
               WgsPoint startPoint,
               int zoom)
Constructor for map component wrapper, that can be used in high level UI components.

Parameters:
label - name for the item, can be null
licenseKey - license key issued by Nutiteq LLC
midlet - MIDlet instance for the application
width - component preferred width.
height - component preferred height.
startPoint - initial middle point on map (in WGS84)
zoom - initial zoom level for display

MapItem

public MapItem(java.lang.String label,
               java.lang.String licenseKey,
               java.lang.String vendor,
               java.lang.String appname,
               int width,
               int height,
               WgsPoint startPoint,
               int zoom)
Constructor for map component wrapper, that can be used in high level UI components.

Parameters:
label - name for the item, can be null
licenseKey - license key issued by Nutiteq LLC
vendor - vendor name for license check
appname - application name for license check
width - component preferred width.
height - component preferred height.
startPoint - initial middle point on map (in WGS84)
zoom - initial zoom level for display
Method Detail

startMapping

public void startMapping()
Initialize needed resources for mapping and start internal threads. This is a required step for application


defineControlKey

public void defineControlKey(int keyCode,
                             int keyValue)
Define Control Keys codes for map manipulation. For example typical Select key: mapItem.defineControlKey(ControlKeys.SELECT_KEY, -5);

Parameters:
keyCode - map component key code, see ControlKeys
keyValue - device key code, for some can use Canvas constants like Canvas.KEY_NUM2

setControlKeysHandler

public void setControlKeysHandler(ControlKeysHandler keysHandler)
Change control keys handler used for actions mapping.

Parameters:
keysHandler - new keys mapping handler

zoomIn

public void zoomIn()
Zoom in map 1 step


zoomOut

public void zoomOut()
Zoom out map 1 step


setMapListener

public void setMapListener(MapListener mL)
Set map listener for receiving callback events from library. "needRepaint" action forwarded from MapListener is used for notifying if displayed map is complete or not. NB! must be AFTER startMapping() call

Parameters:
mL - Listener class reference, e.g. this

setPlaceListener

public void setPlaceListener(PlaceListener pL)
Set Place listener to receive place "mouseover" and selection events

Parameters:
pL - Listener class reference, e.g. this

setErrorListener

public void setErrorListener(ErrorListener eL)
Set listener for component error events (connection errors, license errors, parsing errors etc

Parameters:
eL - Listener class reference, e.g. this

setMiddlePoint

public void setMiddlePoint(WgsPoint wgs,
                           int zoom)
Set middle point of map

Parameters:
wgs - a WgsPoint object
zoom - zoom level, 0 - world to max zoom (17 typically)

setMiddlePoint

public void setMiddlePoint(double lon,
                           double lat,
                           int zoom)
Set Center point of map

Parameters:
lon - longitude, in WGS84 decimal degrees
lat - latitude, in WGS84 decimal degrees
zoom - zoom level, 0 - world to max zoom (17 typically)

getMiddlePoint

public WgsPoint getMiddlePoint()
Get current center point of map

Returns:
a WgsPoint object

mapClicked

public void mapClicked(WgsPoint p)
Event for clicking on map (used in MapListener)

Specified by:
mapClicked in interface MapListener
Parameters:
p - point clicked in WGS84

mapMoved

public void mapMoved()
Event for moving of map (used in MapListener)

Specified by:
mapMoved in interface MapListener

needRepaint

public void needRepaint(boolean mapIsComplete)
Event if map needs repainting (used in MapListener)

Specified by:
needRepaint in interface MapListener
Parameters:
mapIsComplete - is current map view complete (if FALSE, then some map tiles are not yet downloaded)

addPlace

public void addPlace(Place place)
Add Place to map

Parameters:
place - a Place object

addOnMapElements

public void addOnMapElements(OnMapElement[] elements)
Add elements to be displayed on map

Parameters:
elements - elements to be added for display

addPlaces

public void addPlaces(Place[] places)
Add many places to map

Parameters:
places - array of Place objects

removePlace

public void removePlace(Place place)
Remove Place from map

Parameters:
place - the Place object to be removed

removePlaces

public void removePlaces(Place[] places)
remove several places from map

Parameters:
places - array of Place objects

addLine

public void addLine(Line line)
Add single line to map

Parameters:
line - a Line object

addLines

public void addLines(Line[] lines)
Add multiple lines to map

Parameters:
lines - array of Line object
See Also:
Line.Line(WgsPoint[] points, com.nutiteq.components.LineStyle style)

removeLine

public void removeLine(Line line)
Remove previously added line

Parameters:
line - line to be removed

removeLines

public void removeLines(Line[] lines)
Remove multiple lines

Parameters:
lines - lines to be removed

setOnScreenZoomControls

public void setOnScreenZoomControls(OnScreenZoomControls controls)
Set zoom controls to be displayed on screen and used for touch screen zooming.

Parameters:
controls - zoom controls to be used

showZoomLevelIndicator

public void showZoomLevelIndicator(boolean showInicator)
Show map zoom scale after zoom action. Defaults to false.

Parameters:
showInicator - should the zoom indicator be shown

getBoundingBox

public WgsBoundingBox getBoundingBox()
Get Bounding Box of current map view

Returns:
a Bounding Box object

setBoundingBox

public void setBoundingBox(WgsBoundingBox bBox)
Set bounding box for the view. Finds the best zoom level for the bounding box view.

Parameters:
bBox - are to be displayed (in WGS84 coordinates)

getZoomRange

public ZoomRange getZoomRange()
get max and min zoom of current map (typically 0...18)

Returns:
a ZoomRange object

setZoom

public void setZoom(int newZoom)
Set map zoom without changing position.

Parameters:
newZoom - new zoom level

getZoom

public int getZoom()
Get the current zoom level.

Returns:
current zoom level

addKmlService

public void addKmlService(KmlService service)
Add KML layer to the map Usage example: mapItem.addKmlService(new KmlUrlReader("http://www.panoramio.com/panoramio.kml?LANG=en_US.utf8",true));

Parameters:
service - Reference to KML Service, can be own implementation or use KmlUrlReader
See Also:
KmlUrlReader.KmlUrlReader(String, boolean)

getKmlServices

public KmlService[] getKmlServices()
List currently added KML Services

Returns:
array of KmlServices

removeKmlService

public void removeKmlService(KmlService service)
Remove previously added kml service

Parameters:
service - service to be removed

stopMapping

public void stopMapping()
Stop threads started by MapComponent. Called before application exit to clean library resources.


setMap

public void setMap(GeoMap newMap)
Change base map

Parameters:
newMap - reference to the map object
See Also:
CloudMade.CloudMade(String, int, int)

getMap

public GeoMap getMap()
Retrieve currently used map.

Returns:
currently displayed map

getAdditionalInfo

public PlaceInfo getAdditionalInfo(Place place)
Get additional info for internally handled (retrieved from kml service) objects.

Parameters:
place - place associated with internal data
Returns:
info object with additional data

setCursor

public void setCursor(Cursor newCursor)
Replace the default cursor.

Parameters:
newCursor - cursor implementation

removeOnMapElements

public void removeOnMapElements(OnMapElement[] elements)
Remove given elements from map display

Parameters:
elements - elements to be removed

getLibraryLog

public java.lang.String getLibraryLog()
Get internal log for library.

Returns:
internal log

setDownloadStreamOpener

public void setDownloadStreamOpener(DownloadStreamOpener opener)
Set download stream opener, that creates connections to downloaded resources

Parameters:
opener - opener to be used for resources reading

setPanningStrategy

public void setPanningStrategy(PanningStrategy panningStrategy)
Set panning strategy for map component. If not set, the strategy will default to ThreadDrivenPanning

Parameters:
panningStrategy - new panning strategy

setTileSearchStrategy

public void setTileSearchStrategy(GeoMap[] tileSearchStrategy)
Set search strategy for map tile.

Parameters:
tileSearchStrategy - search strategy to be used

setLocationSource

public void setLocationSource(LocationSource marker)
Set location source with GPS marker to be displayed on map

Parameters:
marker - source to be used

removeLocationSource

public void removeLocationSource()
Remove used location source


setNetworkCache

public void setNetworkCache(Cache cache)
Set cache for networking. Currently cached data is:

Parameters:
cache -

addPolygon

public void addPolygon(Polygon polygon)

addPolygons

public void addPolygons(Polygon[] polygons)

removePolygon

public void removePolygon(Polygon polygon)

removePolygons

public void removePolygons(Polygon[] polygons)

enqueueDownload

public void enqueueDownload(ResourceRequestor downloadable,
                            int cacheLevel)
Enqueue new download task to be executed by library.

Parameters:
downloadable - resource to be downloaded
cacheLevel - at which cache levels should response be cached

setZoomLevelIndicator

public void setZoomLevelIndicator(ZoomIndicator zoomIndicator)
Set zoom indicator to be painted on display

Parameters:
zoomIndicator - zoom indicator to use

enableDownloadCounter

public void enableDownloadCounter()
Enable network traffic counter using default implementation ( NutiteqDownloadCounter).


setDownloadCounter

public void setDownloadCounter(DownloadCounter downloadCounter)
Set download counter used for gathering information about network traffic

Parameters:
downloadCounter - implementation used

getDownloadCounter

public DownloadCounter getDownloadCounter()

enableDownloadDisplay

public void enableDownloadDisplay()
Enable network traffic overlay using default implementation for painting ( NutiteqDownloadDisplay).


setDownloadDisplay

public void setDownloadDisplay(DownloadDisplay display)
Set used implementation for network traffic display on map.

Parameters:
display - display used for info show

setFileSystem

public void setFileSystem(FileSystem fs)

setOnMapElementListener

public void setOnMapElementListener(OnMapElementListener listener)