I am trying to put a buffer around a polyline in MapsV2 for android but I haven't find how to do it yet, I was thinking on drawing a polygon around the polyline but also haven't found anyone that have done that, is it possible?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Do you want to draw Path on the map or Do you want to draw straight lines on the map.
In both cases you can follow below code
Above code is to draw only straight lines on Map.
Now if you wanna draw complete path on Map, You would probably need to use google direction api https://maps.googleapis.com/maps/api/directions/
You can use below class to parse response from the same to get total latlngs
And finally you can use this in your class with below code
You need to make sure you are putting it in asyncTask. I hope it will work for you.
in Google's directions api (https://maps.googleapis.com/maps/api/directions/json?origin=75+9th+Ave+New+York,+NY&destination=MetLife+Stadium+1+MetLife+Stadium+Dr+East+Rutherford,+NJ+07073&key=YOUR_API_KEY ) you get one overview_polyline jsonObject, get encoded points From here, and decode it using this method:
You get List of latitude and longitude, now, using google map's getMapAsync Method add this latlng in your map :
I have found a way to add the polylines to the map.
From the above link you need three classes from google maps android util. MathUtil, PolyUtil ans SpheriacalUtil.
I made a function and use Retrofit for connection to Google
The best way to do this would be to use the method
mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(yourBounds,200));
. The second argument (200
) is the padding around the poly line defined inyourBounds
.Here is some example code: