Skip to content

Nextome MapView class

The controller is the interface that the developer see to manage the Nextome Map View. With the controller tha developer can add, modify and remove layers and markers. Can also manage the visibility of the tiles, can navigate programatically on the map and can hande the incoming events like taps.

Declaration

Note

The whole declaration process is described into Initialize section of NextomeMapView documentation.

val mapview: NextomeMapViewHandler = NextomeMapViewHandler()
// Called in your AppDelegate didFinishLaunchingWithOptions
NextomeMapViewHandler.instance.initialize()

// Called in your UIViewController viewDidLoad
var vc = NextomeMapViewHandler.instance.initializeFlutterViewController()
self.present(vc, animated: true)

Initialize

fun initialize(
    fragmentManager: FragmentManager,
    @IdRes viewId :Int,
    context: Context,
): Fragment
// Called in your AppDelegate didFinishLaunchingWithOptions
public func initialize()
// Called in your UIViewController viewDidLoad
public func initializeFlutterViewController() -> FlutterViewController

Important! the APPLY method

A very important thing to know about the controller is that to apply a change to the internal state of the map, is mandatory to call the apply() method. For example if you need to add a marker, or turn-off a layer you must call apply() method to see this changes. Also you can do collect actions like add, modifying, removing, turn-off/on and so on, but at the end you must to call apply() method to see all this change applied. If you don't call the apply() method after your changes, internally the changes are applied but nothing appen to on the screen.

fun apply()
public func apply()

Set resources

Set the resources to initialize the map. In the specific:

  • A list of tiles
  • The zoom level intendeed as the folder depth of provided zip
  • The width and the height of the map related to the size in pixel of the map
  • A flag useMockView that allow to use the map without pass any tile, just for test
  • A flag isLatLng that specify if the coordinate system used will be pixel or latitude-longitude
fun setResources(tiles: List<NMTile>, zoom: Int, width: Int, height: Int, useMockView: Boolean = false, isLatLng: Boolean = false)
public func setResources(tiles: [NMTile], zoom: Int, width: Int, height: Int, useMockView: Bool = false, isLatLng: Bool = false) -> Void

Manage Tiles

Show-hide Tiles

fun setTileVisibility(tileId: String, show: Boolean)
public func setTileVisibility(tileId: String, show: Bool)

Manage Layers

Add Layer

To add a new laye:

fun addLayer(layerId: String)
public func addLayer(layerId: String)

Show-hide Layer

fun setLayerVisibility(layerId: String, show: Boolean)
public func setLayerVisibility(layerId: String, show: Bool)

Clear Layer

Remove all marker from a specific layer

fun clearLayer(layerId: String)
public func clearLayer(layerId: String)

To remove all marker from all layers

fun clearAll()
public func clearAll()

Manage Markers (Marker, Path, Shape)

Add Marker

To add a marker to a layer

fun addMarker(layerId: String, marker: NMMarker)
fun addPath(layerId: String, path: NMPath)
fun addShape(layerId: String, shape: NMShape)
public func addMarker(layerId: String, marker: NMMarker)
public func addPath(layerId: String, path: NMPath)
public func addShape(layerId: String, shape: NMShape)

Update Marker

fun updateMarker(layerId: String, marker: NMMarker)
fun updatePath(layerId: String, path: NMPath)
fun updateShape(layerId: String, shape: NMShape)
public func updateMarker(layerId: String, marker: NMMarker)
public func updatePath(layerId: String, path: NMPath)
public func updateShape(layerId: String, shape: NMShape)

Get Marker

To get a marker, call:

NMMarker? getMarker(String layerId, String markerId);
NMWidgetMarker? getWidgetMarker(String layerId, String markerId);
NMPath? getPath(String layerId, String pathId);
NMShape? getShape(String  layerId, String shapeId);
TODO
TODO

Map behaviour control

Go to point

Move on a specific point. Note that the point must match the coordinates system choose during initialization. You can pass pixel coordinates or lat-long coordinates.

fun goToPosition(x: Double, y: Double)
public func goToPosition(x: Double, y: Double)

Set Zoom

Set the zoom

fun setZoom(zoom: Double)
public func setZoom(zoom: Double)

Enable/Disable the map orientation using device compass

fun useCompass(use: Boolean)
public func useCompass(use: Bool)

Manage Events

Map Ready

Called when all tiles are loaded and showed

fun setOnMapReady( callback: () -> Unit){ this.onMapReady = callback }
private var onMapReady: (() -> Void)? = nil

Map Tap Events

When an empty point on the map is tapped or is pressed for a long time

fun setOnMapTap(callback: (Double, Double) -> Unit){ this.onMapTap = callback }
fun setOnMapLongPress(callback: (Double, Double) -> Unit){ this.onMapLongPress = callback }
private var onMapTap: ((Double, Double) -> Void)? = nil
private var onMapLongPress: ((Double, Double) -> Void)? = nil

Marker Events

Called when a marker (just NMMarker object, not NMPath and NMShape) is tapped

fun setOnMarkerTap(callback: (NMMarker) -> Unit){ this.onMarkerTap = callback }
private var onMarkerTap: ((NMMarker) -> Void)? = nil