-
Notifications
You must be signed in to change notification settings - Fork 14
MapmyIndia GeoFence View
A ready to use UI Widget to create/edit GeoFence in an Android application.
You can add GeoFence view in two ways
- Using XML
- Using Java
<com.mapmyindia.sdk.geofence.ui.views.GeoFenceView
android:id="@+id/geo_fence_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
We can set the following properties:
-
mapmyIndia_geoFence_circleButtonDrawable: To change the circle Button Drawable
-
mapmyIndia_geoFence_polygonButtonDrawable: To change the polygon selector button drawable
-
mapmyIndia_geoFence_circleFillColor: To change Circle Fill colors
-
mapmyIndia_geoFence_circleFillOutlineColor: To change circle Outline color
-
mapmyIndia_geoFence_circleCenterDrawable: To change the image of the center of circle
-
mapmyIndia_geoFence_handToolDrawable: To change action button icon which is visible when polygon is selected
-
mapmyIndia_geoFence_polygonMidPointDrawable: To change midpoint icon of the polygon boundaries
-
mapmyIndia_geoFence_polygonEdgeDrawable: To change polygon corners icon
-
mapmyIndia_geoFence_polygonIntersectionDrawable: To change polygon intersection point icon of polygon
-
mapmyIndia_geoFence_polygonFillColor: To change fill color of polygon
-
mapmyIndia_geoFence_polygonFillOutlineColor: To change outline color of polygon
-
mapmyIndia_geoFence_seekBarThumbDrawable: To change seekbar thumb icon
-
mapmyIndia_geoFence_seekBarProgressPrimaryColor: To change seekbar Progress bar primary color
-
mapmyIndia_geoFence_seekBarProgressSecondaryColor: To change seekbar Progress bar secondary color
-
mapmyIndia_geoFence_seekBarProgressRadius: To change seekbar corner radius
-
mapmyIndia_geoFence_deleteButtonDrawable: To change drawable of Delete button icon
-
mapmyIndia_geoFence_showSeekbar: If its value is false than it hides the seekbar and if its true than it show seekbar
-
mapmyIndia_geoFence_showToolView: If its value is false than it hides the geofence shape toggle buttons and if its true than it show geofence shape toggle buttons
-
mapmyIndia_geoFence_showActionButton: If its value is false than it hides the polygon draw enable/disable button and if its true than it show polygon draw enable/disable button
-
mapmyIndia_geoFence_showUI: If its value is false than it hide all control buttons and if its true than it show all control buttons
-
mapmyIndia_geoFence_showDeleteButton: If its value is false than it hides polygon delete button.
-
mapmyIndia_geoFence_polygonDrawingBackgroundColor: To change the color of Polygon drawing board color.
-
mapmyIndia_geoFence_showPolygonMidPointIcon: To hide polygon mid points icon
-
mapmyIndia_geoFence_polygonOutlineWidth: To set the polygon outline width
-
mapmyIndia_geoFence_circleOutlineWidth: To change the circle outline width
-
mapmyIndia_geoFence_polygonDrawingLineColor: To set the polygon sketch drawing line.
-
mapmyIndia_geoFence_draggingLineColor: To change the dragging line of Polygon edges and circle radius changing line.
-
mapmyIndia_geoFence_minRadius: To set minimum radius of circle.
-
mapmyIndia_geoFence_maxRadius: To set maximum radius of circle
-
mapmyIndia_geoFence_radiusInterval: To set the step size of radius changing
-
mapmyIndia_geoFence_showPolygonCentreIcon: To show/hide centre point of the Polygon
-
mapmyIndia_geoFence_polygonCentreDrawable: To set the drawable for centre point of the Polygon
//To create with default ui and styles
geoFenceView = GeoFenceView(this)
//Or If you want to change the properties of view
geoFenceView = GeoFenceView(this, GeoFenceOptions.builder().showUI(false).build())
GeoFenceOptions has following methods to change the Properties:
-
cicleButtonDrawable(int): To change the circle Button drawable
-
polygonButtonDrawable(int): To change the polygon selector button drawable
-
circleFillColor(int): To change Circle Fill colors
-
circleFillOutlineColor(int): To change circle Outline color
-
circleCentreDrawable(int): To change the image of the center of circle
-
actionButtonDrawable(int): To change action button icon which is visible when polygon is selected
-
polygonMidPointDrawable(int): To change midpoint icon of the polygon boundaries
-
polygonEdgeDrawable(int): To change polygon corners icon
-
polygonIntersectionDrawable(int): To change polygon intersection point icon of polygon
-
polygonFillColor(int): To change fill color of polygon
-
polygonFillOutlineColor(int): To change outline color of polygon
-
seekbarThumbDrawable(int): To change seekbar thumb icon
-
seekbarPrimaryColor(int): To change seekbar Progress bar primary color
-
seekbarSecondaryColor(int): To change seekbar Progress bar secondary color
-
seekbarCornerRadius(int): To change seekbar corner radius
-
deleteButtonDrawable(int): To change drawable of Delete button icon
-
showSeekBar(boolean): If its value is false than it hides the seekbar and if its true than it show seekbar
-
showToolsButton(boolean): If its value is false than it hides the geofence shape toggle buttons and if its true than it show geofence shape toggle buttons
-
showActionButton(boolean): If its value is false than it hides the polygon draw enable/disable button and if its true than it show polygon draw enable/disable button
-
showUI(boolean): If its value is false than it hide all control buttons and if its true than it show all control buttons
-
showDeleteButton(boolean): If its value is false than it hides polygon delete button.
-
polygonDrawingBackgroundColor(int): To change the color of Polygon drawing board color.
-
showPolygonMidPointIcon(boolean): To hide polygon mid points icon
-
polygonOutlineWidth(Float): To set the polygon outline width
-
circleOutlineWidth(Float): To change the circle outline width
-
polygonDrawingLineColor(int): To set the polygon sketch drawing line.
-
draggingLineColor(int): To change the dragging line of Polygon edges and circle radius changing line.
-
minRadius(int): To set minimum radius of circle.
-
maxRadius(int): To set maximum radius of circle
-
radiusInterval(int): To set the step size of radius changing
-
showPolygonCentreIcon(boolean): To show/hide centre point of the Polygon
-
polygonCentreDrawable(int): To set the drawable for centre point of the Polygon
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home)
geoFenceView = findViewById<GeoFenceView>(R.id.geo_fence_view)
geoFenceView.onCreate(savedInstanceState)
geoFenceView.setGeoFenceViewCallback(this)
val geoFence = GeoFence()
geoFence.isPolygon = false
geoFence.circleCenter = LatLng(25.4358, 81.8463)
geoFence.circleRadius = 200
geoFenceView.geoFence = geoFence
}
override fun onResume() {
super.onResume()
geoFenceView.onResume()
}
override fun onStop() {
super.onStop()
geoFenceView.onStop()
}
override fun onStart() {
super.onStart()
geoFenceView.onStart()
}
override fun onLowMemory() {
super.onLowMemory()
geoFenceView.onLowMemory()
}
override fun onDestroy() {
super.onDestroy()
geoFenceView.onDestroy()
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
geoFenceView.onSaveInstanceState(outState)
}
Implement from GeoFenceViewCallback interface
- void onGeoFenceReady(MapboxMap mapmyIndiaMap): When map is loaded successfully
- void geoFenceType(boolean polygon): When toggle between geofence type
- void onCircleRadiusChanging(int radius): When radius of the circle changes
- void onUpdateGeoFence(GeoFence geoFence): On update geofence data
- void hasIntersectionPoints(): When Polygon is intersecting
On circle radius changing:
geoFenceView.onRadiusChange(progress)
On circle radius change finish
geoFenceView.radiusChangeFinish(seekBar?.progress!!)
geoFenceView.enablePolygonDrawing(isChecked)
To draw circle Geofence
geoFenceView.drawCircleGeoFence()
To draw polygon Geofence
geoFenceView.drawPolygonGeofence()
To draw Rectangle Geofence
geoFenceView.drawQuadrilateralGeofence()
geofenceView.setMaxAllowedEdgesInAPolygon(12);
geoFenceView.setOnPolygonReachedMaxPointListener(new OnPolygonReachedMaxPointListener() {
@Override
public void onReachedMaxPoint() {
//show a message to the user
}
})
geofenceView.simplifyWhenIntersectingPolygonDetected(true);
geoFence.setPolygonType(PolygonType.QUADRILATERAL);
//Normal
geoFence.setPolygonType(PolygonType.NORMAL);
geofence.getPolygonCentre()
geoFenceView.convertPointsToClockWise(Orientation.CLOCKWISE);
geoFenceView.setCameraPadding(left, top, right, bottom);
geoFenceView.shouldAllowAutoZoom(false)
For any queries and support, please contact:
Email us at apisupport@mapmyindia.com
Stack Overflow Ask a question under the mapmyindia-api
Support Need support? contact us!
Blog Read about the latest updates & customer stories
© Copyright 2020. CE Info Systems Pvt. Ltd. All Rights Reserved. | Terms & Conditions.
- Map UI Settings
- Set Country Regions
- Set MapmyIndia MapStyle
- REST API Kit
- MapmyIndia GeoAnalytics
- Place Autocomple Widget
- MapmyIndia Safety Plugin
- MapmyIndia Interactive Layer
- MapmyIndia GeoFence View
- MapmyIndia Safety Strip
- MapmyIndia Place Picker
- MapmyIndia Scalebar Plugin
- ELocation Strategy
- MapmyIndia Direction Widget
- MapmyIndia Nearby Search Widget
- Version History
- Country List