{"id":13613719,"url":"https://github.com/utsmannn/SmartMarker","last_synced_at":"2025-04-13T15:33:48.851Z","repository":{"id":47353674,"uuid":"218959863","full_name":"utsmannn/SmartMarker","owner":"utsmannn","description":"Smart helper for marker movement in Google Maps and Mapbox","archived":false,"fork":false,"pushed_at":"2019-12-23T01:38:54.000Z","size":301,"stargazers_count":59,"open_issues_count":1,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-07T21:42:50.177Z","etag":null,"topics":["google-maps","mapbox","marker","marker-animation","marker-tracking"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/utsmannn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-01T09:58:30.000Z","updated_at":"2024-03-13T21:31:30.000Z","dependencies_parsed_at":"2022-08-22T02:01:10.213Z","dependency_job_id":null,"html_url":"https://github.com/utsmannn/SmartMarker","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utsmannn%2FSmartMarker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utsmannn%2FSmartMarker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utsmannn%2FSmartMarker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utsmannn%2FSmartMarker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/utsmannn","download_url":"https://codeload.github.com/utsmannn/SmartMarker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248736396,"owners_count":21153592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google-maps","mapbox","marker","marker-animation","marker-tracking"],"created_at":"2024-08-01T20:00:52.931Z","updated_at":"2025-04-13T15:33:47.532Z","avatar_url":"https://github.com/utsmannn.png","language":"Kotlin","readme":"# Smart Marker For Google Maps and Mapbox\n### This library for helper movement marker in your maps\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://i.ibb.co/Wspktd7/ezgif-com-gif-maker-1.gif\"/\u003e\n\u003c/p\u003e\n\n## Table of Content\n- [Download](https://github.com/utsmannn/SmartMarker#download)\n- [Marker](https://github.com/utsmannn/SmartMarker#add-marker)\n    - [Google Maps](https://github.com/utsmannn/SmartMarker#google-maps)\n    - [Mapbox](https://github.com/utsmannn/SmartMarker#mapbox)\n- [Move Marker](https://github.com/utsmannn/SmartMarker#move-your-marker)\n- [Location Watcher](https://github.com/utsmannn/SmartMarker#location-watcher-extension)\n    - [Installation](https://github.com/utsmannn/SmartMarker#installation)\n    - [Realtime Level](https://github.com/utsmannn/SmartMarker#realtime-level)\n    - [Use](https://github.com/utsmannn/SmartMarker#use)\n    - [Permission Helper](https://github.com/utsmannn/SmartMarker#permission-helper)\n- [Other Extensions](https://github.com/utsmannn/SmartMarker#other-extensions)\n- [Simple Example](https://github.com/utsmannn/SmartMarker#simple-example)\n    - [Google Maps Activity](https://github.com/utsmannn/SmartMarker#google-maps-1)\n    - [Mapbox Activity](https://github.com/utsmannn/SmartMarker#mapbox-1)\n\n## Download\n[ ![Download](https://api.bintray.com/packages/kucingapes/utsman/com.utsman.smartmarker/images/download.svg) ](https://bintray.com/kucingapes/utsman/com.utsman.smartmarker/_latestVersion) \u003cbr\u003e\n```groovy\n\n// the core library\nimplementation 'com.utsman.smartmarker:core:1.3.2@aar'\n\n// extension for google maps\nimplementation 'com.utsman.smartmarker:ext-googlemaps:1.3.2@aar'\n\n// extension for Mapbox\nimplementation 'com.utsman.smartmarker:ext-mapbox:1.3.2@aar'\n\n```\nFor extensions, you don't need to add mapbox extensions if you not use the sdk mapbox. As well as the google map sdk.\n\n## Add Marker\n### Google Maps\nUse the default method as usual for google maps. Reference for add marker in google maps [is here](https://developers.google.com/maps/documentation/android-sdk/map-with-marker) \u003cbr\u003e\nAnd code look like this\n```kotlin\nval markerOption = MarkerOptions()\n        .position(latLng)\n\nval marker = map.addMarker(markerOption) // this your marker\n\n```\n\n### Mapbox\nFor Mapbox, adding marker is little hard, so I create helper for it, ***and you must coding after setup ```style```***\n```kotlin\n// define marker options\nval markerOption = MarkerOptions.Builder() // from 'com.utsman.smartmarker.mapbox.MarkerOptions'\n    .setId(\"marker-id\", true) // if marker id need unique id with timestamp, default is false\n    .setIcon(R.drawable.ic_marker, true) // if marker is not vector, use 'false'\n    .setPosition(latLng)\n    .setRotation(rotation)\n    .build(context)\n\n// add your marker\nval marker = map.addMarker(markerOption)\n```\n\n## Move Your Marker\n```kotlin\nSmartMarker.moveMarkerSmoothly(marker, latLng) \n// or for disable rotation\nSmartMarker.moveMarkerSmoothly(marker, latLng, false)\n\n// with extensions for kotlin\nmarker.moveMarkerSmoothly(latLng)\n// or for disable rotation\nmarker.moveMarkerSmoothly(latLng, false)\n\n```\n\n## Location Watcher Extension\nI create location extensions for get your location every second with old location and new location, you can setup realtime level. \u003cbr\u003e\n\n### Installation\n```groovy\nimplementation 'com.utsman.smartmarker:ext-location:1.2.5@aar'\n\n// for extensions watcher location, you need some library with latest versions\nimplementation 'com.google.android.gms:play-services-location:17.0.0'\nimplementation 'pl.charmas.android:android-reactive-location2:2.1@aar'\nimplementation 'io.reactivex.rxjava2:rxjava:2.2.12'\nimplementation 'io.reactivex.rxjava2:rxandroid:2.1.1'\nimplementation 'com.karumi:dexter:6.0.0'\n```\n\n### Realtime Level\nYou can setup realtime level for get every second update, `locationWatcher.getLocationUpdate(priority, listener)`\n\n\n| level | ms |\n| -- | -- |\n| `LocationWatcher.Priority.JEDI` | 3 ms |\n| `LocationWatcher.Priority.VERY_HIGH` | 30 ms |\n| `LocationWatcher.Priority.HIGH` | 50 ms |\n| `LocationWatcher.Priority.MEDIUM` | 300 ms |\n| `LocationWatcher.Priority.LOW` | 3000 ms |\n| `LocationWatcher.Priority.VERY_LOW` | 8000 ms |\n\n### Use\n```kotlin\n// define location watcher\nval locationWatcher: LocationWatcher = LocationWatcher(context)\n\n// get location once time\nlocationWatcher.getLocation { location -\u003e\n    // your location result\n}\n\n// get location update every second\nlocationWatcher.getLocationUpdate(LocationWatcher.Priority.HIGH, object : LocationUpdateListener {\n    override fun oldLocation(oldLocation: Location?) {\n        // your location realtime result\n    }\n    \n    override fun newLocation(newLocation: Location?) {\n        // your location past with delay 30 millisecond (0.03 second)\n    }\n\n    override fun failed(throwable: Throwable?) {\n        // if location failed\n    }\n})\n\n// stop your watcher in onStop activity\noverride fun onDestroy() {\n    locationWatcher.stopLocationWatcher()\n    super.onDestroy()\n}\n\n```\n\n### Permission helper\nIf you have not applied location permission for your app, you can be set permission with adding context before listener.\n```kotlin\n// get location once time with permission helper\nlocationWatcher.getLocation(context) { location -\u003e\n    // your location result\n}\n\n// get location update every second with permission helper\nlocationWatcher.getLocationUpdate(context, LocationWatcher.Priority.HIGH, object : LocationUpdateListener {\n    override fun oldLocation(oldLocation: Location?) {\n        // your location realtime result\n    }\n    \n    override fun newLocation(newLocation: Location?) {\n        // your location past with delay 30 millisecond (0.03 second)\n    }\n\n    override fun failed(throwable: Throwable?) {\n        // if location failed\n    }\n})\n```\n\nDon't forget to add location permission ```android.permission.ACCESS_FINE_LOCATION``` for your apps\n```xml\n\u003cuses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/\u003e\n```\n\n## Other Extensions\n```kotlin\n// Convert Location to LatLng for Google Maps ('com.google.android.gms.maps.model.LatLng')\nlocation.toLatLngGoogle()\n\n// Convert Location to LatLng for Mapbox ('com.mapbox.mapboxsdk.geometry.LatLng')\nlocation.toLatLngMapbox()\n\n// use marker as vector for Google Maps\nbitmapFromVector(context, R.drawable.marker_vector)\n\n```\n\n## Simple Example\n### Google Maps\n```kotlin\nclass MainActivity : AppCompatActivity() {\n\n    private lateinit var locationWatcher: LocationWatcher\n    private var marker: Marker? = null\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        setContentView(R.layout.activity_main)\n\n        locationWatcher = LocationWatcher(this)\n        val googleMapsView = (google_map_view as SupportMapFragment)\n\n        locationWatcher.getLocation(this) { loc -\u003e\n            googleMapsView.getMapAsync {  map -\u003e\n                val markerOption = MarkerOptions()\n                    .position(loc.toLatLngGoogle())\n                    .icon(bitmapFromVector(this@MainActivity, R.drawable.ic_marker))\n\n                marker = map.addMarker(markerOption)\n                map.animateCamera(CameraUpdateFactory.newLatLngZoom(loc.toLatLngGoogle(), 17f))\n            }\n        }\n\n        // device tracker\n        locationWatcher.getLocationUpdate(this, LocationWatcher.Priority.HIGH, object : LocationUpdateListener {\n            override fun oldLocation(oldLocation: Location) {\n\n            }\n\n            override fun newLocation(newLocation: Location) {\n                // move your marker smoothly with new location\n                marker?.moveMarkerSmoothly(newLocation.toLatLngGoogle())\n                                    \n                // or use class SmartMarker for java\n                // SmartMarker.moveMarkerSmoothly(marker, newLocation.toLatLngMapbox())    \n            }\n\n            override fun failed(throwable: Throwable?) {\n            }\n        })\n    }\n}\n```\n### Mapbox\n```kotlin\nclass MainActivity : AppCompatActivity() {\n\n    private lateinit var locationWatcher: LocationWatcher\n    private var marker: Marker? = null // from 'com.utsman.smartmarker.mapbox.Marker'\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        // setup instance with api key mapbox before 'setContentView'\n        Mapbox.getInstance(this, \"sk.eyJ1Ijoia3VjaW5nYXBlcyIsImEiOiJjazI1eXFqYzQxcGZjM25ueTZiMHU3aDl3In0.EfIuu2NSv2CacIKEhkXhCg\")\n        setContentView(R.layout.activity_main)\n\n        locationWatcher = LocationWatcher(this)\n      \n        locationWatcher.getLocation(this) { loc -\u003e\n            mapbox_view.getMapAsync {  map -\u003e\n                \n                // set style before setup your marker\n                map.setStyle(Style.OUTDOORS) { style -\u003e \n                \n                    val markerOption = MarkerOptions.Builder() // from 'com.utsman.smartmarker.mapbox.MarkerOptions'\n                           .setId(\"marker-id\")\n                           .addIcon(R.drawable.ic_marker, true)\n                           .addPosition(loc.toLatLngMapbox())\n                           .build(this)\n    \n                    val markerLayer = map.addMarker(markerOption)\n                    marker = markerLayer.get(\"marker-id\")\n                    \n                    map.animateCamera(CameraUpdateFactory.newLatLngZoom(loc.toLatLngGoogle(), 17f))\n                }\n            }\n        }\n\n        // device tracker\n        locationWatcher.getLocationUpdate(this, LocationWatcher.Priority.HIGH, object : LocationUpdateListener {\n            override fun oldLocation(oldLocation: Location) {\n\n            }\n\n            override fun newLocation(newLocation: Location) {\n                // move your marker smoothly with new location\n                marker?.moveMarkerSmoothly(newLocation.toLatLngGoogle())\n\n                // or use class SmartMarker for java\n                // SmartMarker.moveMarkerSmoothly(marker, newLocation.toLatLngMapbox())  \n            \n            }\n\n            override fun failed(throwable: Throwable?) {\n            }\n        })\n    }\n}\n```\n\n\n## My Other Libraries\n- [Recycling](https://github.com/utsmannn/Recycling) \u003cbr\u003e\nA Library for make an easy and faster RecyclerView without adapter\n\n- [rmqa](https://github.com/utsmannn/rmqa)\u003cbr\u003e\nRabbit Message Queue for Android\n\n- [Anko Navigation Drawer](https://github.com/utsmannn/AnkoNavigationDrawer)\u003cbr\u003e\nLibrary for implementation Navigation Drawer with styles in Anko\n\n- [Easy Google Login](https://github.com/utsmannn/EasyGoogleLogin)\u003cbr\u003e\nLibrary for Simplify Firebase Authenticate Google Auth\n---\n```\nCopyright 2019 Muhammad Utsman\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n---\nmakasih","funding_links":[],"categories":["Android"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futsmannn%2FSmartMarker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futsmannn%2FSmartMarker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futsmannn%2FSmartMarker/lists"}