PMMapDataModel
class PMMapDataModel(mapDataModelCallback: PMMapDataModelCallback = object : PMMapDataModelCallback {})
Manage map markers displayed on map. Provide the instance of this class to PMMapView.init and use PMMapDataModel's methods to alter content displayed on map.
Samples
import android.app.Fragment
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.sygic.profi.sdk.party.PartyConfigProduction
import com.sygic.profi.sdk.party.map.PMMapError
import com.sygic.profi.sdk.party.map.PMMapView
import com.sygic.profi.sdk.party.map.PMMapViewAvailabilityCallback
import com.sygic.profi.sdk.party.map.PMMapViewConfig
fun main() {
//sampleStart
class MapViewFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View {
return PMMapView(context = activity).apply {
init(
mapViewConfig = PMMapViewConfig(TARGET_SYGIC_PACKAGE_NAME, PartyConfigProduction),
mapViewAvailabilityCallback = object : PMMapViewAvailabilityCallback {
override fun onMapDestroyed() {
Log.d("Map", "Map is destroyed based on view's lifecycle")
}
override fun onMapError(error: PMMapError) {
Log.d("Map", "Error rendering map. Create new PMMapView and try again. Cause: $error")
}
override fun onMapReady() {
Log.d("Map", "Map is ready to be used")
}
},
mapDataModel = PMMapDataModelHolder.mapDataModel,
mapCameraModel = PMMapCameraModelHolder.mapCameraModel
)
}
}
}
//sampleEnd
}import android.graphics.BitmapFactory
import android.util.Log
import com.sygic.profi.model.pm.map.PMMapPosition
import com.sygic.profi.sdk.party.map.PMMapDataModel
import com.sygic.profi.sdk.party.map.PMMapDataModelCallback
fun main() {
//sampleStart
object PMMapDataModelHolder {
val mapDataModel = PMMapDataModel(mapDataModelCallback = object : PMMapDataModelCallback {
override fun onSuccess(action: PMMapDataModelCallback.Action) {
Log.d("Map", "Map action success: $action")
}
override fun onFailure(action: PMMapDataModelCallback.Action, exception: Throwable) {
Log.d("Map", "Map action failed: $action")
}
})
fun addMarker() {
val bitmap = BitmapFactory.decodeFile("your/path/to/bitmap")
mapDataModel.addMarkers(
listOf(
PMMapDataModel.PMMapMarker(
bitmap = bitmap,
position = PMMapPosition(latitude = 45.18, 50.19),
markerIconAnchorX = .5f,
markerIconAnchorY = 0f,
minVisibleZoomLevel = 2f,
maxVisibleZoomLevel = 10f,
),
PMMapDataModel.PMMapMarker(
bitmap = bitmap,
position = PMMapPosition(latitude = 45.38, 50.09),
markerIconAnchorX = .5f,
markerIconAnchorY = 0f,
minVisibleZoomLevel = 1f,
maxVisibleZoomLevel = 15f,
),
)
)
}
fun removeMarker() {
val existingMarkers = mapDataModel.getMarkers()
mapDataModel.removeMarkers(existingMarkers.first().markerId)
}
}
//sampleEnd
}Constructors
Link copied to clipboard
fun PMMapDataModel(mapDataModelCallback: PMMapDataModelCallback = object : PMMapDataModelCallback {})
Types
Link copied to clipboard
class MapMarkerIconTooLargeException(markers: List<PMMapDataModel.PMMapMarker>) : IllegalStateException
Map marker can not reference bitmaps larger than 500KB
Link copied to clipboard
data class PMMapMarker(val markerId: String = UUID.randomUUID().toString(), val bitmap: Bitmap, val position: PMMapPosition, val markerIconAnchorX: Float = 0.5f, val markerIconAnchorY: Float = 0.5f, val minVisibleZoomLevel: Float = 0.0f, val maxVisibleZoomLevel: Float = 22.0f)
Representation of marker displayed on map
Functions
Link copied to clipboard
Add the map marker to map view associated with this PMMapDataModel. If you need to add multiple markers, use method addMarkers(marker: List
Link copied to clipboard
Add multiple map markers to map view associated with this PMMapDataModel If you want to add multiple markers, prefer this method over addMarker(marker: PMMapMarker).
Link copied to clipboard
Get markers associated with this PMMapDataModel
Link copied to clipboard
Remove all map markers from map view associated with this PMMapDataModel
Link copied to clipboard
Remove map markers from map view associated with this PMMapDataModel