|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectView
com.ls.widgets.map.MapWidget
public class MapWidget
Constructor Summary | |
---|---|
MapWidget(Bundle bundle,
Context context,
java.io.File rootMapFolder,
int initialZoomLevel)
Creates instance of map widget. |
|
MapWidget(Bundle bundle,
Context context,
java.lang.String rootMapFolder,
int initialZoomLevel)
Creates instance of map widget. |
|
MapWidget(Context context,
java.io.File rootMapFolder)
Creates instance of map widget. |
|
MapWidget(Context context,
java.io.File rootMapFolder,
int initialZoomLevel)
Creates instance of map widget. |
|
MapWidget(Context context,
java.lang.String rootMapFolder)
Creates instance of map widget. |
|
MapWidget(Context context,
java.lang.String rootMapFolder,
int initialZoomLevel)
Creates instance of map widget. |
Method Summary | |
---|---|
void |
addMapEventsListener(MapEventsListener listener)
Adds listener for map events. |
void |
centerMap()
Centers the map. |
void |
centerMapHorizontally()
Centers the map horizontally |
void |
clearLayers()
Removes all graphical object from all layers |
void |
computeScroll()
|
MapLayer |
createLayer(long theLayerId)
Creates new map layer with a given id. |
OfflineMapConfig |
getConfig()
Returns the copy of the map widget's configuration |
GPSConfig |
getGpsConfig()
Returns GPSConfig object that will allow you to configure the GPS receiver. |
Layer |
getLayer(int index)
Returns map layer by index. |
Layer |
getLayerById(long id)
Returns map layer by layer id. |
int |
getLayerCount()
Returns total layer count |
MapGraphicsConfig |
getMapGraphicsConfig()
|
int |
getMapHeight()
Returns height of the map taking current scale into account. |
int |
getMapWidth()
Returns width of the map taking current scale into account. |
int |
getOriginalMapHeight()
Returns the height of the map on the max zoom level. |
int |
getOriginalMapWidth()
Returns the width of the map on the max zoom level. |
float |
getScale()
Returns the current scale of the map. |
int |
getZoomLevel()
Returns current zoom level of the map. |
void |
jumpTo(int x,
int y)
Scrolls map to specific location |
void |
jumpTo(Location location)
Scrolls the map to specific location without animation. |
void |
jumpTo(Point location)
Scrolls the map to specific location. |
void |
jumpToCurrentLocation()
Scrolls the map to current location marker without animation. |
void |
onChangePinVisibility(boolean visible)
|
boolean |
onKeyDown(int keyCode,
KeyEvent event)
|
void |
onMovePinTo(Location location)
|
boolean |
onTouchEvent(MotionEvent event)
|
void |
removeAllLayers()
Removes all layers from the map. |
void |
removeAllMapEventsListeners()
Removes all map event listeners. |
void |
removeLayer(long theLayerId)
Removes layer with the given id from the map. |
void |
removeMapEventsListener(MapEventsListener listener)
Removes map event listener from the map. |
void |
saveState(Bundle bundle)
Saves mapWidget internal state, that can be restored from onCreate(); |
void |
scrollMapTo(int x,
int y)
Scrolls the map to specific location using scroll animation. |
void |
scrollMapTo(Location location)
Scrolls the map to specific location using scroll animation. |
void |
scrollMapTo(Point location)
Scrolls the map to specific location using scroll animation. |
void |
scrollToCurrentLocation()
Scrolls the map to current location marker using scroll animation. |
void |
setAnimationEnabled(boolean isEnabled)
Enables/disables the zoom in/zoom out animations |
void |
setMaxZoomLevel(int maxZoomLevel)
The max zoom level the user can zoom in to. |
void |
setMinZoomLevel(int minZoomLevel)
Sets the min zoom level the user can zoom out to. |
void |
setOnDoubleTapListener(OnMapDoubleTapListener listener)
Sets the listener to handle double tap event. |
void |
setOnLocationChangedListener(OnLocationChangedListener listener)
Sets listener for retrieving the location |
void |
setOnLongClickListener(OnLongClickListener listener)
Sets the listener to handle long click event. |
void |
setOnMapLongClickListener(OnMapLongClickListener onMapLongClickListener)
Sets the listener to handle long click on the map. |
void |
setOnMapScrolledListener(OnMapScrollListener mapScrollListener)
Sets scroll listener to the map. |
void |
setOnMapTilesFinishLoadingListener(OnMapTilesFinishedLoadingListener listener)
Sets the listener that will be called when all visible tiles has been loaded and displayed. |
void |
setOnMapTouchListener(OnMapTouchListener mapTouchListener)
Sets touch listener to the map. |
void |
setOnTouchListener(OnTouchListener listener)
Sets the listener to handle touch events |
void |
setScale(float scale)
Set's the scale to the map. |
void |
setShowMyPosition(boolean show)
Shows current position of the user on the map. |
void |
setTouchAreaSize(int pixels)
Sets the size of the touch area when user touches the map. |
void |
setUseSoftwareZoom(boolean useSoftwareZoom)
Enables the map to keep zooming in when no more zoom levels left. |
void |
setZoomButtonsVisible(boolean enabled)
Enables or disables the standard zoom controls. |
void |
zoomIn()
Zooms map in by one zoom level. |
void |
zoomIn(int pivotX,
int pivotY)
|
void |
zoomOut()
Zooms map out by one zoom level. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MapWidget(Context context, java.lang.String rootMapFolder, int initialZoomLevel)
context
- - contextrootMapFolder
- - folder that contains map resources inside your assets.initialZoomLevel
- - initial zoom level.public MapWidget(Context context, java.io.File rootMapFolder, int initialZoomLevel)
context
- - contextrootMapFolder
- - instance of File that points to the map resources which are
located on the external storage.initialZoomLevel
- - initial zoom levelpublic MapWidget(Context context, java.lang.String rootMapFolder)
context
- - ContextrootMapFolder
- - folder that contains map resources inside your assets.public MapWidget(Context context, java.io.File rootMapFolder)
context
- - ContextrootMapFolder
- - instance of File that points to the map resources which are
located on the external storage.public MapWidget(Bundle bundle, Context context, java.io.File rootMapFolder, int initialZoomLevel)
bundle
- - bundle that were used to save map widget's state.context
- - ContextrootMapFolder
- - instance of File that points to the map resources which are
located on the external storage.initialZoomLevel
- - zoom level that will be set in case if bundle doesn't
contain previously saved state.public MapWidget(Bundle bundle, Context context, java.lang.String rootMapFolder, int initialZoomLevel)
bundle
- - bundle that were used to save map widget's state.context
- - ContextrootMapFolder
- - folder that contains map resources inside your assets.initialZoomLevel
- - zoom level that will be set in case if bundle doesn't
contain previously saved state.Method Detail |
---|
public void addMapEventsListener(MapEventsListener listener)
listener
- - instance of MapEventListenerpublic MapLayer createLayer(long theLayerId)
theLayerId
- - id of the new layer
java.lang.IllegalArgumentException
- when layer with the given id exists already.public void removeLayer(long theLayerId)
theLayerId
- the id of previously created layer.public void removeAllLayers()
public void centerMapHorizontally()
public Layer getLayer(int index)
index
- the index of the layer
java.lang.ArrayIndexOutOfBoundsException
- when index is out of bounds.public Layer getLayerById(long id)
id
- - layer id
public int getLayerCount()
public int getMapHeight()
public int getMapWidth()
public int getOriginalMapHeight()
public int getOriginalMapWidth()
public OfflineMapConfig getConfig()
public float getScale()
public int getZoomLevel()
public boolean onKeyDown(int keyCode, KeyEvent event)
public boolean onTouchEvent(MotionEvent event)
public void removeMapEventsListener(MapEventsListener listener)
listener
- instance of the MapEventsListenerpublic void removeAllMapEventsListeners()
public void clearLayers()
public void setOnMapTouchListener(OnMapTouchListener mapTouchListener)
mapTouchListener
- instance of OnMapTouchListener.public void setOnMapLongClickListener(OnMapLongClickListener onMapLongClickListener)
onMapLongClickListener
- - instance of OnMapLongClickListener
. Can be null.public void setOnMapTilesFinishLoadingListener(OnMapTilesFinishedLoadingListener listener)
listener
- instance of OnMapTilesFinishedLoadingListener or null.public void setOnMapScrolledListener(OnMapScrollListener mapScrollListener)
mapScrollListener
- instance of OnMapScrollListener.public void setOnLocationChangedListener(OnLocationChangedListener listener)
listener
- - instance of OnLocationChangedListener. May be null.public void setOnLongClickListener(OnLongClickListener listener)
listener
- instance of OnLongClickListener. Can be null.android.view.View.OnLongClickListener
public void setOnDoubleTapListener(OnMapDoubleTapListener listener)
listener
- instance of OnMapDoubleTapListener. Can be null.OnMapDoubleTapListener
public void setOnTouchListener(OnTouchListener listener)
listener
- instance of OnTouchListenerandroid.view.View.OnTouchListener
public void setZoomButtonsVisible(boolean enabled)
enabled
- true in order to make zoom controls visible, otherwise false.public void setMinZoomLevel(int minZoomLevel)
minZoomLevel
- int from 0 to count of zoom levels.public void setMaxZoomLevel(int maxZoomLevel)
maxZoomLevel
- int from 0 to max zoom levels.public void setScale(float scale)
scale
- scale value. 2.0 means that you want to make map two times
bigger.public void setUseSoftwareZoom(boolean useSoftwareZoom)
useSoftwareZoom
- true if you want to enable software zoom, false otherwise.public void setAnimationEnabled(boolean isEnabled)
isEnabled
- true if you want to enable the animations, false otherwise.public void setTouchAreaSize(int pixels)
pixels
- radius of the touch area in pixelspublic void zoomIn()
public void setShowMyPosition(boolean show)
In order to calibrate the map you should add the calibration data to the
map.xml. Calibration data consists of two points - top left and bottom
right. X and Y is a coordinate of the point in your original map image in
pixels. lat and lon is latitude and longitude of the same point in real
world.
For example, your map.xml may look like this:
<Image TileSize="256" Overlap="1" Format="png"> <Size Width="1918" Height="978"/> <CalibrationRect> <Point x="0" y="0" lat="42.924251753870685" lon="-103.99658203125" topLeft="1"/> <Point x="1918" y="978" lat="40.81380923056961" lon="-98.3056640625"/> </CalibrationRect> </Image>
show
- - set true in order to show the position marker on the map,
false - in order to hide it.
java.lang.IllegalStateException
- () in case if map is not calibrated.public MapGraphicsConfig getMapGraphicsConfig()
public GPSConfig getGpsConfig()
public void zoomIn(int pivotX, int pivotY)
public void zoomOut()
public void computeScroll()
public void onMovePinTo(Location location)
onMovePinTo
in interface MapLocationListener
public void onChangePinVisibility(boolean visible)
onChangePinVisibility
in interface MapLocationListener
public void jumpToCurrentLocation()
public void scrollToCurrentLocation()
public void jumpTo(Location location)
location
- - instance of android.location.Location
object.
java.lang.IllegalStateException
- if map was not calibrated. For more details see
MapWidget.setShowMyPosition().public void jumpTo(Point location)
location
- - instance of Point. The coordinates of the point should be
set in pixels in map coordinate system.public void jumpTo(int x, int y)
x
- - x coordinate in map coordinate system.y
- - y coordinate in map coordinate system.public void scrollMapTo(Location location)
location
- - instance of android.location.Location
.
java.lang.IllegalStateException
- if map is not calibrated. For more details see
MapWidget.setShowMyPosition().public void scrollMapTo(Point location)
location
- - instance of android.graphics.Point
. Coordinates of
the point should be set in pixels in map coordinates.public void scrollMapTo(int x, int y)
x
- - x coordinate of the point in map coordinates.y
- - y coordinate of the point in map coordinates.public void saveState(Bundle bundle)
bundle
- public void centerMap()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |