I have data in this format:
POINT(73.0166738279393 33.6788721326803)
MULTILINESTRING((73.0131224998036 33.679001500419,73.0119635003153 33.678392400389,73.0119205001311 33.6783781002692),(73.0131224998036 33.679001500419,73.0136031002029 33.6783443999742),(73.0136031002029 33.6783443999742,73.0147099372139 33.67685138958),(73.0147099372139 33.67685138958,73.0150124997272 33.6770292997624,73.0154158996241 33.6773507003746,73.0157677998441 33.6776577999676,73.016042399737 33.6779721004322,73.0162998999205 33.6783149004124,73.0166738279393 33.6788721326803))
Now I want to draw it on Google Maps in Android. I make an array of names and coordinates.
ArrayList<String> coordinates = new ArrayList<String>
coordinates.add(tvcoor.getText().toString());
This produces an error: when I run my application, it stops forcefully. And how can I draw it on a map?
Try this ,
String str;
ArrayList<String> coordinates = new ArrayList<String>();
First get string from textview.
str = textview.getText().toString();
Second remove brackets.
str = str.replaceAll("\\(", "");
str = str.replaceAll("\\)", "");
Then split with comma and add values to arraylist.
String[] commatokens = str.split(",");
for (String commatoken : commatokens) {
System.out.println("-" + commatoken + "-");
coordinates.add(commatoken);
}
Then we get separate coordinates value at index position ,
for (int i = 0; i < coordinates.size(); i++) {
String[] tokens = coordinates.get(i).split("\\s");
for (String token : tokens) {
System.out.println("-" + token + "-");
}
}