The question is pretty straightforward, but I'll give you some more context: My team is trying to make an Android application where the users can highlight a certain section of a street, color it, and send that information to a server. I've already started playing around with the Google Maps API V2, but so far the only thing I've got is a working map with zoom buttons. I've also read this thread possible to highlight a section of a street?, but there's nothing on how the user can do this from an app, instead. I was wondering, first, if this is possible at all, and second, how could it be done. Thank you.
I figured out how to do this, but it is very specific to my location, Colombia. Since Colombian street addresses are formatted "Carrera (number) #(number)-(number)" or "Calle (number) #(number)-(number)"
and the Geocoder handles addresses in Colombia like this "Carrera (number1) #(number2)-(number3) a #(number2)-(number4)" where number3 is the beginning of the street, and number4 the end of the street, what I did was a series of splits:
private Polyline crearPolyline(List<Address> a2, GoogleMap map) {
Address ad = a2.get(0);
String address = ad.getAddressLine(0);
System.out.println(address);
//Gets "number3 a #number2-number4"
String[] addressSplit = address.split("-");
String addressA = null, addressB = null;
Polyline p = null;
try {
//Gets number3 and "a " number4
String[] addressSplit2 = addressSplit[1].split(" a ");
//Start address for the polyline
addressA=addressSplit[0]+"-"+addressSplit2[0]+", Bogotá";
LatLng a = getLatLongFromAddress(addressA);
//End address for the polyline
addressB=addressSplit[0]+"-"+addressSplit[2]+", Bogotá";
LatLng b = getLatLongFromAddress(addressB);
System.out.println(addressA);
System.out.println(addressB);
p = map.addPolyline(new PolylineOptions().add(a,b).color(Color.BLUE));
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Procure tocar calles rectas", Toast.LENGTH_LONG).show();
//If the polyline can't be painted, the street might not be straight.
}
return p;
}
I hope this makes sense for anyone that hasn't been to Colombia.