malikdawar / drawroute

DrawRoute wraps Google Directions API (https://developers.google.com/maps/documentation/directions/) using RxJava for Android so developers can download, parse and draw path on the map in very fast and flexible way (For now only JSON support).
MIT License
90 stars 17 forks source link

Missing feature to remove route. #14

Closed KristinnGodfrey closed 1 month ago

KristinnGodfrey commented 3 years ago

I want to clear a drawn route before drawing another one. For all I can see, there is no way that handles that scenario.

KristinnGodfrey commented 3 years ago

My current implementation is to googleMap.clear() and then add everything to the map again. That doesn't seem very efficient. Code for reference:

override fun onInfoWindowClick(p0: Marker) {
        val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment
        val homeLatLng = LatLng(64.13963469616142, -21.9518070894305)
        mapFragment.getMapAsync { googleMap ->
            googleMap.clear()
            addMarkers()
            map.addMarker(MarkerOptions().position(LatLng(64.13963469616142, -21.9518070894305)))
            googleMap.run {
                //Called the drawRouteOnMap extension to draw the polyline/route on google maps
                drawRouteOnMap(
                    mapsApiKey=getString(R.string.google_maps_key), //your API key
                    source = homeLatLng, // Source from where you want to draw path
                    destination = p0.position, // destination to where you want to draw path
                    markers = false,
                    travelMode = TravelMode.WALKING,
                    context = this@MainActivity //Activity context

                )
            }
        }
    }
malikdawar commented 2 years ago

Hay @KristinnGodfrey thanks man, sounds really a good option to have. I would love to work on it.

cwbsl commented 1 year ago

Any update on this? Love the library, thanks a lot for the great work! This feature (Being able to remove them again would be very helpful for us as well since we keep updating the route from the current user location to the destination. We have over 300 markers on the map and always removing and readding them slows things down quite a bit...

AdamNizam commented 6 months ago

Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugCompileClasspath'. = maven { url = uri("https://jitpack.io") }

malikdawar commented 1 month ago

Sorry guys, i know it's too late but this new release: worth a look https://github.com/malikdawar/drawroute.

Changelog: 1- Added the remove path feature 2- Optimized the response time with the help of Kotlin coroutines 3- Remove the dependencies on Rx, that was making the build heavy.