location - Android google maps - make polyline more straighter /smoother -
i creating app draw walking path gps. okay, path drawing when walk, have 1 question - possible somehow make path line straighter programmatically?
for example. first, after walking see path this(it not polyline, polygon in example, think idea): https://www.dropbox.com/s/763mq0wja6x7lpy/11.png
but after saving, app made path more straighter/smoother: https://www.dropbox.com/s/npwkz9coqve7m4g/22.png
how this? because don't have idea.
i drawing path locationlistener
:
locationmanager locationmanager = (locationmanager)this.getsystemservice(context.location_service);
criteria criteria = new criteria(); //criteria.setpowerrequirement(criteria.power_low); criteria.setaccuracy(criteria.accuracy_fine); criteria.setaltituderequired(false); criteria.setbearingrequired(false); criteria.setcostallowed(true); criteria.setspeedrequired(false); string bestprovider = locationmanager.getbestprovider(criteria, true); locationmanager.requestlocationupdates(bestprovider, 500, 3, );
and onlocationchanged listener:
@override
public void onlocationchanged(location location) {if(lastlocationloc == null) lastlocationloc = location; latlng lastlatlng= locationtolatlng(lastlocationloc); latlng thislatlng= locationtolatlng(location); mmap.addpolyline (new polylineoptions().add(lastlatlng).add(thislatlng).width(4).color(color.red)); lastlocationloc = location; }
the locationmanager never give exact locations. therefore, while may not walking in non-smooth way, gps coordinates jumpy, if set high accuracy in criteria.
so, when draw path, may consider using android's path api
for code on this, @ answer:
Comments
Post a Comment