Discussion Forums  >  Maps, Device Location, Tracking

Replies: 0    Views: 94

WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
04/01/13 02:27 PM (11 years ago)

Need a little tweak on a little custom Android code

I have some custom code I've used over the last couple years in several apps that worked well in 1.4 apps. I've snipped out the part I need to put into the BT_screen_map.java but there is a "field BT_item.latitude not visible" and "field BT_item.longitude not visible" error. The fix is easy I bet, I just can't extract it from my somewhat fried grey matter. The snippet below: //build the location string to show on the devices location bubble double tmpDegrees = Double.parseDouble(tappedLocation.latitude); int Ldegrees = (int)tmpDegrees; double Ldecimal = Math.abs(Double.parseDouble(tappedLocation.latitude) - Ldegrees); double Lminutes = Ldecimal * 60; double tmplDegrees = Double.parseDouble(tappedLocation.longitude); int ldegrees = (int)tmplDegrees; double ldecimal = Math.abs(Double.parseDouble(tappedLocation.longitude) - ldegrees); double lminutes = ldecimal * 60; //number formatter object java.text.NumberFormat f = java.text.NumberFormat.getInstance(); f.setMaximumFractionDigits(2); //format double values for output. String Lmin = f.format(Lminutes); String lmin= f.format(lminutes); //create string with a line-break in between the N and W values String locationDegreesString = "N " + Ldegrees + "° " + Lmin + "'" + "\nW " + ldegrees + "° " + lmin + "'"; //address is an array to hold all the 'parts' of the address List<android.location.Address> address; try { android.location.Geocoder geoCoder = new android.location.Geocoder(getApplicationContext()); address = geoCoder.getFromLocation(tmpDegrees, tmplDegrees, 1); //append thouroughfare and locality to message locationDegreesString += "\n" + address.get(0).getThoroughfare() + " " + address.get(0).getLocality(); } catch (java.io.IOException e) { //could not find address? locationDegreesString += "\nUnknown Street Address"; } //pass string to showAlert('title', 'description') method showAlert("Your Location", locationDegreesString); //End change title on call-out Thanks, Tim
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.