Place Picker Widget
Introduction
Mappls Place Picker Plugin can be used to choose a specific location.
Add the dependency
Add below dependency in app level build.gradle file
implementation 'com.mappls.sdk:place-widget:2.0.0'
Add Place Picker
To add the place picker widget
java
Intent intent = new PlacePicker.IntentBuilder()
.placeOptions(placePickerOptions).build(this);
startActivityForResult(intent, 101);
Kotlin
val intent = PlacePicker.IntentBuilder()
.placeOptions(placePickerOptions).build(this)
startActivityForResult(intent, 101)
You can use PlacePickerOptions
to set the following properties:
toolbarColor(Integer)
: To set the toolbar color of place widgetstartingBounds(LatLngBounds)
: To open a map in a boundstatingCameraPosition(CameraPosition)
: To open a map that sets in camera poition you can set zoom, centre, bearing etc.,includeDeviceLocationButton(Boolean)
: To enable/ disable current location functionalitymarker(Integer)
: To change the marker image which is visible in the centre of a mapmapMaxZoom(Double)
: To set maximum zoom level of the mapmapMinZoom(Double)
: To set minimum zoom level of the mapincludeSearch(Boolean)
: To provide opions for search locationssearchPlaceOption(PlaceOptions)
: To set all the properties of search widget
Get Result
To get the pick place:
java
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 101 && resultCode == RESULT_OK) {
Place place = PlacePicker.getPlace(data);
}
}
Kotlin
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if(requestCode == 101 && resultCode == Activity.RESULT_OK) {
val place: Place? = PlacePicker.getPlace(data!!)
}
}