2

I have this link:

http://travelplanner.mobiliteit.lu/hafas/query.exe/dot?performLocating=2&tpl=stop2csv&stationProxy=yes &look_maxdist=150&look_x=6112550&look_y=49610700 

and the response of the call is:

id=A=1@O=Belair, Sacré-Coeur@X=6,113204@Y=49,610279@U=82@L=200403005@B=1@p=1459856195;

I want to get X and Y from this response and put them into a marker on the map & the code I've written never works.

How can I get the response in order to use it again?

Daniel
  • 2,355
  • 9
  • 23
  • 30
tarif aljnidi
  • 21
  • 1
  • 3

1 Answers1

1

Since you didn't provide us with a piece of your code, I can only blindly answer to your question.

Getting the X and the Y is as simple as writing an appropriate regex that will get it for you. The next and the last step is to add the marker to the map.

Pattern pattern = Pattern.compile("X=(?<x>.+?)@Y=(?<y>.+?)@");
Matcher matcher = pattern.matcher("id=A=1@O=Belair, Sacré-Coeur@X=6,113204@Y=49,610279@U=82@L=200403005@B=1@p=1459856195;");

if (matcher.find()) {
    double x = Double.parseDouble(matcher.group("x").replace(",", "."));
    double y = Double.parseDouble(matcher.group("y").replace(",", "."));

    map.addMarker(new MarkerOptions()
        .position(new LatLng(x, y))
        .title("New Marker"));
}

Of course do not hardcode the string to match, it's only for an example, and you should get it from the HTTP response.

itachi
  • 3,389
  • 2
  • 24
  • 29