0

We have now created an app that can recieve data via bluetooth and displays this data in a list on the application. This data gives the latitude and longitude of the hiders device.

We now only don't know how to convert this text into a variable for the latitude and a variable of the longitude so that we can create a marker of the location on the map.

Added is a link to the github file of our application. In the Main2activity you can see the information coming in and in the Map activity the variables of the hider should be replaced by the latitude and longitude coming in.

https://github.com/vogeltjeeva/SmartSeek

Share a link to this question (includes your user id)
| edit | | close | delete |
0

I cannot find your Main2activity.java there, it is not here... can you send a direct link to its page on Github?

Share a link to this answer (includes your user id)
| edit | delete |
0

Does strInput contain the coordinates received from the device? Lets assume you get the String strInput like "41.40338, 2.17403" (Decimal degrees (DD)) and you want to add that on a map with a marker, then in an onmapready callback, you can do a conversion like:

// conversion:
String lat_s = strInput.substring(0, strInput.indexOf(",") );
String lng_s = strInput.substring(strInput.indexOf(" ")+1 );

double lat = Double.parseDouble(lat_s);
double lng = Double.parseDouble(lng_s);
System.out.println("lat="+lat+" lng="+lng);

// show map with marker:
LatLng sydney = new LatLng(lat, lng);
googleMap.addMarker(new MarkerOptions()
    .position(sydney)
    .title("Device is here"));

But depending on the format of the String you receive, the conversion might be different. Some examples are shown here, using the Location class.

Share a link to this answer (includes your user id)
| edit | delete |

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.