Monday, 15 October 2018

Hot to get list of Lat Longs of a certain type using google places api without double requesting?

This is my code

mGeoDataClient.getAutocompletePredictions("Supermarket", null, null).addOnSuccessListener {
        it.forEach {
            it.placeId?.let {
                mGeoDataClient.getPlaceById(it).addOnSuccessListener {
                    val marker = it[0].latLng
                    val name = it[0].name.toString()
                    mMap.addMarker(MarkerOptions().position(marker).title(name))
                }
            }
        }
    }

For every supermarket it finds it has to request again to get the lat long as this information isn't included on the autocomplete prediction, only the place id.

Is there a better way of doing this?



from Hot to get list of Lat Longs of a certain type using google places api without double requesting?

No comments:

Post a Comment