Pointr SDK Map Widget¶
This document is a collection of how-to guides and tutorials that involve the usage of Pointr’s SDK Map Widget. Information about how to use your own custom map widgets won’t be covered in this document. To learn how to setup the SDK map widget in first place, use the Getting Started guide.
Important concepts¶
To understand this guide it is necessary to understand some important concepts when dealing with our map widget.
- POI: Acronym for Point of Interest, this refers to any potential destinations user might have on a map, or places where you want users to click and see information.
- Highlight: When a POI is selected by the user (or programatically) it is guaranteed to be displayed even if there is a
clash
happening, also non-highligted POIs might get hidden or faded to facilitate the user experience. - Clash: This refers to what happens when two icons rendered by the map are too close to the point of being useless or confusing, there is an algorithm to detect this happening and hiding some of them.
Table of contents¶
- Map widget actions
- Map controls
- Map visual customization
- Custom map content
- Map widget orientation support
Map widget actions¶
This guide aims to show some example use cases with the Pointr Map Widget to provide guidance to client developers when implementing custom use cases using the Pointr Map.
In the following code samples, a valid PTRMapWidget
instance is assumed to be created before. Also, the poi
is assumed to be a variable of type POI
, and fetched from PoiManager
as non-null prior to executing the code samples.
The type POI
is a type about “Points of Interest”.
Showing route summary view to a point of interest¶
mapWidgetFragment.showRouteSummary(poi)
let poi = // Get poi from PTRPoiManager (Pointr.shared.poiManager)
let location = Pointr.shared.positionManager?.lastValidCalculatedLocation
let path = Pointr.shared.pathManager?.calculatePath(from: location, toNearestLocationIn: [poi]) // Path can also be calculated between two pois
mapWidget.showRouteSummary(path: path, destination: poi)
Focusing on a point of interest¶
mapWidgetFragment.showPoiDetails(poi)
let poi = // Get poi from PTRPoiManager (Pointr.shared.poiManager)
mapWidget.showPoiDetails(poi)
Creating a pathsession¶
val pathSession = Pointr.getPointr()?.pathManager?.startPathSession(listOf(poi))
pathSession?.let { safeSession ->
mapWidgetFragment.showPathFinding(safeSession)
}
let poi = // Get poi from PTRPoiManager (Pointr.shared.poiManager)
let pathSession = Pointr.shared.pathManager?.startPathSession(withDestinations: [poi])
mapWidget.showPathFinding(pathSession: pathSession, destination: poi)
Handler and Listener Logic¶
This section explains the general usage of Handler
s and Listener
s in the MapWidget.
The components that are in the PTRMapWidget have default behaviors. The design for these are based off from past experience with clients to accommodate as many use cases as possible. However, each client has their own specific cases and there may be some cases where you want to modify the default behavior of the components. To do this, you should use Handlers, which will allow you to override the default behavior of the components. If you only want to get updates of the events from the PTRMapWidget, you should use Listeners. Listeners are interfaces, and Handlers are concrete classes that implement these interfaces.
Note
If you only want to change the behavior of certain events of a component, you can override only those events in the handler instance you assign. The unimplemented callbacks will continue to perform the default behavior.
Note
You can augment the default behavior of the components by using handlers as well. For example, you can override the mapDidReceiveTapOnPoi, show a popup upon poi click, then call super.mapDidReceiveTapOnPoi to pass the event to the handler and preserve the default action as well.
Warn
You will lose default functionality if you override these handlers without calling the super function. For example, if you override the ExitButtonEventsHandler onExitClicked method, the exit button will lose its default behavior which is to finish the activity.
Below are some examples of these handlers, each of them are implementing their respective listeners. In order to add a listener please check the interface these handlers implement, then create a class that implements this interface, and add it as a listener to map widget. You will find code snippets of an example to this further along the doc.
This handler allows you to modify the default behavior of map related events. For example, you can change the action performed when the user clicks on a Marker, by overriding the mapDidReceiveTapOnMarker callback. More information on MapEvents can be found here
This handler allows you to modify the default behavior of the events triggered by the search bar. For example, you can change the action performed when a POI is selected from the search suggestions.
This handler allows you to modify the default behavior of the events triggered by the POI Detail view. It is the view that shows up when a POI is selected. Overriding this handler will allow you to perform custom actions upon events from this view. i.e. you can override the onPoiDetailViewAction callback, which will allow you to implement custom behavior upon clicking ‘Navigate’.
This handler allows you to modify the default behavior of the events triggered by the Route Summary View. It is the view that shows up after ‘Navigate’ button is clicked on the POI Detail View. To give an example, if you override this handler, you can modify the default behavior upon user clicking to start a pathfinding session by overriding the onRouteSummaryViewAction callback.
This handler allows you to modify the default behavior of the events triggered by the Level Selector View. It is the view on the bottom right of the screen that allows the users to browse the levels of the map manually. For example, you can modify the behavior upon selecting a level from the selector by overriding the onLevelSelected callback.
This handler allows you to modify the default behavior of tracking mode events. These events are related to controlling the mode changes of the map. You can get more information related to this here
For more information on other handlers please refer to the api docs section of the corresponding platform.
You can find code snippets to add a handler and listener below;
- To add a handler, you can create a new handler instance for the desired component, override the methods according to your use case and assign it to the related handler on map widget.
class MyPoiDetailsEventsHandler: PTRPoiDetailsEventsHandler {
override func poiDetails(_ poiDetails: PTRPoiDetailViewController, onEvent event: PTRPoiDetailsEvent) {
switch event {
case PTRPoiDetailsEvent.shown:
// Add custom action upon show
break
case PTRPoiDetailsEvent.directionsToPoi:
// Add custom action upon navigate
break
default:
super.poiDetails(poiDetails, onEvent: event)
}
}
}
...
widget.poiDetailsEventsHandler = MyPoiDetailsEventsHandler(mapWidget: widget)
widget.poiDetailEventsHandler = object : PoiDetailsEventsHandler(widget) {
override fun onPoiDetailViewAction(
poiDetailsView: PoiDetailsView,
poiDetailViewAction: PoiDetailViewAction,
poi: Poi?
) {
when (poiDetailViewAction) {
PoiDetailViewAction.Navigate -> {
// Add custom action upon navigate
}
PoiDetailViewAction.Show -> {
// Add custom action upon show
}
else -> {
// For all other actions keep the default behavior
super.onPoiDetailViewAction(poiDetailsView, poiDetailViewAction, poi)
}
}
}
}
- To add a listener, you should create a class that implements the interface for the desired component, override the callbacks to perform actions upon events, and add it as a listener to Map Widget.
extension WidgetContainerViewController: PTRPoiDetailsEventsListener {
private var widget: PTRMapWidgetViewController?
func poiDetails(_ poiDetails: PTRPoiDetailViewController, onEvent event: PTRPoiDetailsEvent) {
// Perform actions upon Poi detail view action. This will NOT modify/remove the default
// behavior, but augment it.
}
func registerToListeners() {
// register to listeners
widget?.poiDetailViewController?.addListener(self)
}
}
widget.addListener(object : PoiDetailEventsListener {
override fun onPoiDetailViewAction(
poiDetailsView: PoiDetailsView,
poiDetailViewAction: PoiDetailViewAction,
poi: Poi?
) {
// Perform actions upon Poi detail view action. This will NOT modify/remove the default
// behavior, but augment it.
}
})
Map controls¶
This section has guides on how to control the map, move it, zoom, and so on.
Zoom into a POI or location¶
To scroll the map to a specific location, you can use the following method of the PTRMapViewController, which is accessible from the PTRMapWidgetViewController:
func scrollToCoordinate(_ coordinate: CLLocationCoordinate2D)
Example code: (enter the latitude and longitude of your choice)
mapWidget.mapViewController.scrollToCoordinate(CLLocationCoordinate2D(latitude: latitude, longitude: longitude))
This will pan the camera to the given coordinate
.
To scroll the map to a specific location, and also set a zoom level, you can use the following method of the PTRMapViewController, which is accessible from the PTRMapWidgetViewController:
func scrollToCoordinate(_ coordinate: CLLocationCoordinate2D, zoomLevel: Double)
Example code: (enter the latitude and longitude and zoomLevel of your choice)
mapWidget.mapViewController.scrollToCoordinate(CLLocationCoordinate2D(latitude: latitude, longitude: longitude), zoomLevel: zoomLevel)
This will change the zoom level to zoomLevel
param, and pan the camera to the given coordinate
.
Zoom Level values are as below, for more information refer to this article on maplibre/mapbox manual..
To zoom the map to a specific location, with defaultLocationZoomLevel amount, you should use the following method of PTRMapViewController, which is accessible from PTRMapWidgetViewController:
func zoomToCoordinate(_ coordinate: CLLocationCoordinate2D)
Example code: (enter the latitude and longitude of your choice)
mapWidget.mapViewController.zoomToCoordinate(CLLocationCoordinate2D(latitude: latitude, longitude: longitude))
This will pan to the given coordinate
, and set the zoom level to defaultLocationZoomLevel
To scroll the map to a specific location, you can use the following method of the PTRMapFragment, which is accessible from the PTRMapWidgetFragment:
fun scrollToLocation(location: GeoPoint)
Example code: (enter the latitude and longitude of your choice)
ptrMapWidget.mapFragment?.scrollToLocation(GeoPoint(latitude, longitude))
This will only pan the camera to the specified location without changing the zoom level.
To scroll the map to a specific location, and also set a zoom level, you can use the following method of the PTRMapFragment, which is accessible from the PTRMapWidgetFragment:
fun scrollToLocation(location: GeoPoint, zoomLevel: Double)
Example code: (enter the latitude and longitude and zoomLevel of your choice)
ptrMapWidget.mapFragment?.scrollToLocation(GeoPoint(latitude, longitude), zoomLevel)
This will change the zoom level to ‘zoomLevel’ param, and pan the camera to the given ‘location’.
Zoom Level values are as below, for more information refer to this article on maplibre/mapbox manual..
To zoom the map to a specific location, with defaultLocationZoomLevel amount, you should use the following method of PTRMapFragment, which is accessible from PTRMapWidgetFragment:
fun zoomToLocation(location: GeoPoint)
Example code: (enter the latitude and longitude of your choice)
ptrMapWidget.mapFragment?.zoomToLocation(GeoPoint(latitude,longitude))
This will pan to the given location, and set the zoom level to ‘defaultLocationZoomLevel’
Change zoom level or rotation of map¶
To zoom into the map to a desired zoom level, you can use the following method of the PTRMapViewController, which is accessible from the PTRMapWidgetViewController:
func setZoomLevel(_ zoomLevel: Double, animated: Bool)
Example code:
mapWidget.mapViewController.setZoomLevel(10.0, animated: true)
Zoom Level values are as below, for more information refer to this article on maplibre/mapbox manual..
To rotate the map to a desired orientation, you can use the following method of the PTRMapViewController, which is accessible from the PTRMapWidgetViewController:
func rotateToDirection(_ direction: CLLocationDirection, animated: Bool)
Example code:
mapWidget.mapViewController.rotateToDirection(50.0, animated: true)
To rotate the map to a desired orientation, you can use the following method of the PTRMapFragment, which is accessible from the PTRMapWidgetFragment:
fun setZoomLevel(zoomLevel: Double, isAnimated: Boolean)
Example code:
widget.mapFragment?.setZoomLevel(10.0, true)
fun rotateToDirection(direction: Double, isAnimated: Boolean)
Example code:
widget.mapFragment?.rotateToDirection(90.0, true)
Highlighting a map drawable on the map¶
To highlight a POI, you should call the following method of PTRMapViewController, accessible from PTRMapWidgetViewController:
func highlightPoi(_ poi: PTRPoi)
Example code: (enter the POI of your choice)
mapWidget.mapViewController.highlightPoi(poi)
This will make the POI icon and POI text color different, and make sure it is visible in the map independent of the POI clash algorithm. Only one POI can be highlighted at a time. If you try to highlight a second poi, the previous one will automatically be unlighlighted.
To unhighlight a Poi, you should call the following method of PTRMapViewController, accessible from PTRMapWidgetViewController:
func unhighlightPoi()
Example code:
mapWidget.mapViewController.unhighlightPoi()
This will remove the highlight of the given Poi. It will revert the icon color and text color of the POI to the original color.
To highlight a POI, you should call the following method of PTRMapFragment, accessible from PTRMapWidgetFragment:
fun highlightPoi(poi: Poi)
Example code: (enter the POI of your choice)
ptrMapWidget.mapFragment?.highlightPoi(poi)
This will make the POI icon and POI text color different, and make sure it is visible in the map independent of the POI clash algorithm. Only one POI can be highlighted at a time. If you try to highlight a second poi, the previous one will automatically be unlighlighted.
To unhighlight a Poi, you should call the following method of PTRMapFragment, accessible from PTRMapWidgetFragment:
fun unhighlightPoi(poi: Poi)
Example code:
ptrMapWidget.mapFragment?.unhighlightPoi(poi)
This will remove the highlight of the given Poi. It will revert the icon color and text color of the POI to the original color.
Map visual customization¶
The following guides explain how to customize Pointr’s map widget while still using it. Note that these guides doesn’t explain how to use a completely custom and unrelated map widget.
Change POI views¶
Changing POI views is currently not possible programmatically, but Pointr can provide a customized design upon request.
Change pinview¶
Changing the pin view is currently not possible programmatically, but Pointr can provide a customized design upon request.
Customize the path line displayed on the map¶
Changing the path view is currently not possible programmatically, but Pointr can provide a customized design upon request.
Custom map content¶
The guides on this section explain how to show content on the map that wasn’t generated automatically by some other means.
Adding a static path to Pointr map¶
To add a static path on the map, all you need to do is set the currentPath
field of the PTRMapViewController
/PTRMapFragment
to the PTRPath
/Path
object you have. Since v7, the SDK handles the path staying on the map upon level changes, so you only need to call it once and it will be drawn on the map across levels.
let source = PTRLocation(coordinate: CLLocationCoordinate2D(sourceLatitude, sourceLongitude), level: sourceLevel)
let destination = PTRLocation(coordinate: CLLocationCoordinate2D(destinationLatitude, destinationLongitude), level: destinationLevel)
let path = Pointr.shared.pathManager?.calculatePath(fromLocation: source, toNearestLocationIn: [destination])
mapWidget.mapViewController.currentPath = path
val source = Location(GeoPoint(sourceLatitude, sourceLongitude), sourceLevel)
val destination = Location(GeoPoint(destinationLatitude, destinationLongitude), destinationLevel)
val path = Pointr.getPointr()?.pathManager?.calculatePath(source, listOf(destination))
mapWidget.mapFragment?.currentPath = path
To remove the static path, this field should be set to null.
mapWidget.mapViewController.currentPath = nil
mapWidget.mapFragment?.currentPath = null
Below example describes how we can get a static path between two arbitrary points on the map. When we tap on a map, we can hit a Poi
, Feature
, Marker
, or a Location
. All these classes are subclasses of LocationAware
. For path calculation we need a source LocationAware
object and a destination LocationAware
object. We can ask user to mark the source and destinations by tapping onto the map.
class WidgetContainerViewController: UIViewController {
enum MapAction{
case source
case destiantion
}
// to decide on which variable to set: source or destination
var action = MapAction.source
var source: PTRLocationAware? = nil
var destination: PTRLocationAware? = nil
...
private func registerToListeners() {
...
// register to map events
mapWidget.mapViewController.addListener(self)
}
// use this function to calculate path and show it on the map
private func setPath() {
guard let source = self.source else {
return
}
guard let destination = self.destination else {
return
}
let path = Pointr.shared.pathManager?.calculatePath(fromLocation: source, toNearestLocationIn: [destination])
mapWidget.mapViewController.currentPath = path
}
// use this function to clear the path
private func clearPath() {
mapWidget.mapViewController.currentPath = nil
}
}
extension WidgetContainerViewController: PTRMapEventsListener {
func map(_ map: PTRMapViewController, didReceiveTapOnMarker marker: PTRMapViewMarker) {
assignMarker(marker)
}
private func assignMarker(_ marker: PTRMapViewMarker) {
if (marker is PTRPoi) { // marker can be of type POI
assignMarker(marker as! PTRPoi)
} else if (marker is PTRFeature) { // marker can be of type Feature
assignLocationAware(marker as! PTRFeature)
} else { // create location from marker
if let location = getLocation(from: marker) {
assignLocationAware(location)
} else {
print("tapped to an invalid locaiton")
}
}
}
private func assignLocationAware(_ locationAware: PTRLocationAware) {
switch(action) {
case .source:
source = locationAware
break
default:
destination = locationAware
break
}
}
private func getLocation(from marker: PTRMapViewMarker) -> PTRLocation? {
guard let mapLevel = marker.mapLevel else {
print("cannot calculate route for location outside the site")
return nil
}
guard let site = Pointr.shared.siteManager?.site(withInternalIdentifier: mapLevel.siteId) else {
print("unable to get site")
return nil
}
guard let building = site.buildings.filter({ $0.internalIdentifier == mapLevel.buildingId }).first else {
print("unable to get building")
return nil
}
guard let level = building.levels.filter({ $0.index == mapLevel.levelIndex }).first else {
print("unable to get level")
return nil
}
return PTRLocation(coordinate: marker.coordinate, level: level)
}
}
enum class MapAction {
source,
destination
}
var source: LocationAware? = null
var destination: LocationAware? = null
// to decide on which variable to set: source or destination
var action = MapAction.source
widget.addListener(object : MapEventsListener {
override fun mapDidReceiveTapOnPoi(mapFragment: PTRMapFragment, poi: Poi) {
assign(poi)
}
override fun mapDidReceiveTapOnFeature(
mapFragment: PTRMapFragment,
feature: Feature
) {
assign(feature)
}
override fun mapDidReceiveTap(
mapFragment: PTRMapFragment,
tappedLocation: CalculatedLocation
) {
assign(tappedLocation)
}
private fun assign(locationAware: LocationAware) {
when (action) {
MapAction.source -> source = locationAware
else -> destination = locationAware
}
}
})
// use this function to calculate path and show it on the map
private fun setPath() {
val source = this.source ?: return
val destination = this.destination ?: return
val path = Pointr.getPointr()?.pathManager?.calculatePath(source, listOf(destination))
mapWidget.mapFragment?.currentPath = path
}
// use this function to clear the path
private fun clearPath() {
mapWidget.mapFragment?.currentPath = null
}
Filter POIs on the map¶
To filter POIs on the Pointr Map, you should set the following field of PTRMapViewController:
var filteredPoiSet: Set<String>? = nil
This is initialized as nil. When it is nil, all POIs are shown by default. If you want to show only specific POIs, you should get the id’s of the POIs you want to display, and create a list of these ids, then set this variable to the list you have created. If later you want to remove the filtering and show all POIs, you can set it back to nil. Remember that this affects all levels, not just the current visible level. Also, once this is set, it filters the POIs immediately. You do not need to call an extra refresh or change level call.
Example code: (let’s say you want to show only ‘Restroom’ POIs, in building with identifier = 1)
let buildingId = 1
guard let building = Pointr.shared.siteManager?.buildingWithInternalIdentifier(buildingId) else { return }
let restroomsIds = Pointr.shared.poiManager?.pois(for: building, withName: "Restroom")?.getPoiList()?.map { $0.identifier }
mapWidget.mapViewController.filteredPoiSet = restroomsIds
To filter the pois, you will need to utilise the filteredPoiSet field of the PTRMapFragment. This field takes in a list of String’s which are to be the id’s of the pois that you want to filter on map. So, if you want to show POIs “poi1”, “poi2”, “poi3” , you would call:
pointrMapWidget.getMapFragment?.filteredPoiSet = listOf("poi1", "poi2", "poi3")
Custom POI highlighting¶
POIs can be categorized to different types. You can define types for POIs using dashboard. Please check here about how to define types for POIs.
Only the POIs that belong to a specific type can be displayed using PTRMapViewController.filteredPoiSet
API. Available POI types can be retrieved using POI Manager.
let types = Pointr.shared.poiManager?.poiTypes(for: site)
Check POIManagerInterface API for other available functions.
Only the POIs that belong to a specific type can be displayed using PTRMapFragment.filteredPoiSet
API. Available POI types can be retrieved using POI Manager.
val type = Pointr.getPointr()?.poiManager?.getAllPoiTypes(site)
Check PoiManager API for other available functions.
POIs that belog to a certain type can be filtered using following code
let pois = Pointr.shared.poiManager?.pois(for: site, withTypes: [type])?.getPoiList()
mapViewController.filteredPoiSet = Set(pois.compactMap { poi in
return poi.identifier
})
val pois = Pointr.getPointr()?.poiManager?.getPois(site, listOf(type))?.poiList ?: emptyList()
mapFragment.filteredPoiSet = pois.map { it.id }
Instead of types, POIs can be filtered based on categories available
guard let categories = Pointr.shared.poiManager?.categories().filter { $0.title == "<category name>" } else { return }
guard categories.isEmpty else { return }
let category = categories.first
let pois = Pointr.shared.poiManager?.pois(for: site, with: category, buildingOnFocus: nil).getPoiList()
mapViewController.filteredPoiSet = Set(pois.compactMap { poi in
return poi.identifier
})
val category = Pointr.getPointr()?.poiManager?.getCategories()?.firstOrNull() ?: return@addLayer
val pois = Pointr.getPointr()?.poiManager?.getPois(site = building.site!!, poiCategory = category) ?: return@addLayer
mapFragment.filteredPoiSet = pois.map { it.id }
Highlighting the POIs requires a (custom drawing)[/docs/8.x/Developer%20Portal/Pointr%20Mobile%20SDK/Guides/Custom%20Drawings/]. A layer should be added to describe how the highlighted POI is going to look like. A layer can be added after map ends loading.
let layerIdentifier = "custom_poi_highlight"
...
// register to map events
mapWidget.mapViewController.addListener(self)
...
func mapWillStartLoadingBaseLayers(_ map: PTRMapViewController) {
let layer = PTRMapSymbolLayer(identifier: layerIdentifier)
layer.iconImage = UIImage(named: "ic_custom_poi_highlight")
layer.iconImageName = "ic_custom_poi_highlight"
layer.iconAllowsOverlap = true
map.addLayer(layer)
}
val layerIdentifier = "custom_poi_highlight"
...
mapWidget.addListener(object : MapEventsListener) {
override fun mapDidEndLoading(mapFragment: PTRMapFragment) {
val layer = PTRMapSymbolLayer(layerIdentifier).apply {
iconImage = ContextCompat.getDrawable(context, R.drawable.ic_custom_poi_highlight)
iconImageIdentifier = "ic_custom_poi_highlight"
iconAllowOverlap = true
}
mapFragment.addLayer(layer) { isSuccess, error ->
if (!isSuccess) {
Log.e(TAG, "Failed to add layer: $error")
return@addLayer
}
Log.i(TAG, "Layer added successfully")
}
}
}
After adding the layer, a (PTR)Feature
can be generated using POI information and to highlight when a POI is selected.
func select(poi: PTRPoi) {
let geometry = PTRGeoPoint(coordinate: poi.location.coordinate)
var location = PTRLocation(coordinate: poi.location.coordinate)
if let level = poi.location.level {
location = PTRLocation(coordinate: poi.location.coordinate, level: level)
}
let feature = PTRFeature(typeCode: "custom_feature", geometry: geometry, location: location!, externalId: poi.identifier)
mapViewController.addFeatures([feature], toLayer: layer.identifier)
// remove the poi id to hide it
mapViewController.filteredPoiSet?.remove(poi.identifier)
}
fun select(poi: Poi) {
val feature = Feature(
externalIdentifier = poi.id,
geometry = poi.geometry!!,
location = poi.location,
)
mapFragment.addFeatures(listOf(feature), layer.identifier) { isSuccess, error ->
if (!isSuccess) {
Log.e(TAG, "Failed to add feature: $error")
return@addFeatures
}
Log.i(TAG, "Feature added successfully")
// remove the poi id to hide it
mapFragment.filteredPoiSet = mapFragment.filteredPoiSet?.minusElement(poi.id)
}
}
Notice that here, Feature external identifier is set to POI’s id. This way we can refer to one another later on. We could have used extra field to store POI id as well.
Unhighligh/unselect operations is going to be doing the opposite
func unselect(feature: PTRFeature) {
mapViewController.removeFeatures([feature])
// add back the poi
mapViewController.filteredPoiSet?.insert(feature.externalId)
}
fun unselect(feature: Feature) {
mapFragment.removeFeatures(listOf(feature)) { isSuccess, error ->
if (!isSuccess) {
Log.e(TAG, "Failed to remove feature: $error")
return@removeFeatures
}
Log.i(TAG, "Feature removed successfully")
// add back the poi
mapFragment.filteredPoiSet =
mapFragment.filteredPoiSet?.plusElement(feature.eid)
}
}
Modifying Pointr map widget components¶
PTRMapWidgetConfiguration¶
Similar to Android, this class is used to define the configuration of the Map Widget. It contains options of including/hiding UI components along with several functional preferences which change the way MapWidget operates. This tutorial will focus on the UI customizations of this class.
The PTRMapWidgetViewController can be created using this configuration by either using an empty initialization or by sending the required configuration.
Empty argument initialiser:¶
let configuration = PTRMapWidgetConfiguration()
Static default configuration call:¶
let configuration = PTRMapWidgetConfiguration.defaultConfiguration()
Static map only configuration call:¶
let configuration = PTRMapWidgetConfiguration.mapOnlyConfiguration()
You can check for all the public initialisers of this class in the API Reference - iOS section of the Pointr Documentation Center.
After initializing a PTRMapWidgetConfiguration object, you can modify the fields as per your needs. An example to this is, let’s say you want to disable Search bar;
configuration.isSearchEnabled = false
PTRMapWidgetConfiguration¶
This class is used to define the configuration of the Map Widget. It contains options of including/hiding UI components along with several functional preferences which change the way MapWidget operates. This tutorial will focus on the UI customizations of this class.
You can create an instance of this class by simply calling it with an empty argument constructor, or you can use the predefined static methods which gives you a template instance of this class. These templates were tailored from experience with past clients, according to the needs of the majority.
After creating an instance of this class, you should feed it as argument while creating the PTRMapWidgetFragment as follows;
PTRMapWidgetFragment.newInstance(ptrMapConfiguration)...
Below are some examples of how to create configuration objects;
Empty argument constructor:¶
val ptrMapConfiguration = PTRMapWidgetConfiguration()
Static default configuration call:¶
val ptrMapConfiguration = PTRMapWidgetConfiguration.defaultConfiguration()
Static map only configuration call:¶
val ptrMapConfiguration = PTRMapWidgetConfiguration.mapOnlyConfiguration()
You can check for all the public constructors of this class in the javadoc section of the Pointr Docs.
After initializing a PTRMapWidgetConfiguration object, you can modify the fields as per your needs. An example to this is, let’s say you want to disable Search bar;
ptrMapConfiguration.isSearchEnabled = false
Map widget orientation support¶
This section explains screen orientation support of the SDK.
We do not support landscape orientation mode on the map widget. Map widget will not rotate if it is directly presented without a parent view controller. However, if it is presented as a child of another view controller or if it is embedded in a navigation controller or a tab bar controller, rotation of the map widget should be disabled through that parent view controller. Only portrait orientation mode should be allowed.
The code snippet below should be added to the corresponding parent view controller that will present the map widget.
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .portrait
}
We do not support landscape orientation mode on the map widget. Only portrait orientation mode should be allowed. Activities containing map widget should have android:screenOrientation="portrait"
attribute on AndroidManifest.xml
file.
<activity
android:name=".map.MapActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"