Skip to content

Common Use Cases

This page list common use cases that can be implemented with the SDK and links to the appropriate modules and methods, to give a hint how to solve them. It will not provide complete example code.

Show Pop up when POI is clicked

Detecting if a POI is clicked can be done via the class PoiSearch. Basically you search at the clicked position (probably you have to transform screen coordinates to internal geo coordinates) if a currently visible POI is inside a defined radius. The radius is passed to the PoiSearch in meters, it has to increase with increasing viewing height.

  1. Transform the click position to internal coordinates by Mapviewer.getGeoCoordFromFrameCoord()
  2. Get the list of currently visible POI Categories (this also includes self created Waypoint shown by Mapviewer.showWaypoint())
  3. Calculate the search radius taking the zoomlevel into account: Multiply the desired pixel count with Mapviewer.getGroundResolution()
  4. Register the callbacks of the PoiSearch
  5. Execute the search PoiSearch.searchPoisAroundPoint() and pass the search position, radius and visible PoiCategory.
  6. The TaskListener.taskFinished() will indicate the end of the search. Check the BaseTask.getReturnValue() for the correct execution and the Task.getReturnValue() for the found Waypoint.

Get address of the map center when map movement stops

To calculate the address of the current map center, the Geocoder provides the Geocoder.getNearestAddressByRadius() and Geocoder.getNearestAddressByCount() methods. Movements of the map can be detected by the SDK's MapviewerListener.mapMotionStart() and MapviewerListener.mapMotionStop().

  1. Implement the MapViewer callbacks to receive the MapviewerListener.mapMotionStop()
  2. Implement the Geocoder callbacks to receive the TaskListener.taskFinished()
  3. Get the center coordinates of the map by Mapviewer.getCenterPoint()
  4. Use the Geocoder.getNearestAddressByCount() method and pass the center point and the count of the addresses you want to find to start the geocoding task
  5. The TaskListener.taskFinished() will indicate the end of the geocoding. Check the BaseTask.getReturnValue() for the correct execution and the Task.getReturnValue() for the found Waypoint.

Changing the Position icon

The position icon can be activated by the method Mapviewer.showVehicleIcon() respectivily the showVehicleIcon XML tag. The vehicle icon is located in the resource folder /poi_icons/CarIcon__*. The car icon can be defined separately for the perspective 2D and 3D. Additionally, the car icon is present in a version for indicating a valid GPS position and a bad / no GPS position which is indicated by a trailing "_grey"

The default car icons are:

  • CarIcon_2d.png
  • CarIcon_2d_grey.png
  • CarIcon_3d.png
  • CarIcon_3d_grey.png

The default car icons are:

  • truck_2d.png
  • truck_2d_grey.png
  • truck_3d.png
  • truck_3d_grey.png

The file name and size can be changed at runtime by the method Mapviewer.setVehicleIconBaseName().

1
mapViewer.setVehicleIconBaseName("truck", 1.0)

In contrast to other POI icons, the vehicle icon is automatically scaled when zooming in the map. Additionally, it changes it's orientation according to the GPS orientation. Those two properties can be deactivated in the mapservices.xml configuration file ( f.e. orientation changes are not desired if you use a non circular Icon like a pin ).