Possible to display a "Location" object in a Datafield?

Hi,

My Datafield contains an abstract location. I want to display this abstract location in MGRS or UTM format - rather than the default format in degrees. I am not sure how to do this, other than through the SDK-provided function "toGeoString" which requires that I have/use a Position object. However it seems the Position object is off limits to normal Datafields. Any alternatives or tricks? I guess I could look up how to convert degrees to UTM..

if (abstractLocation != null) {

//this is what I want to work, but gives a "Permission required" error
var abstractLocationForDisplayInMGRS = new Pos.Location({
:latitude => abstractLocation[0],
:longitude => abstractLocation[1],
:format => :degrees
});
var mgrsStr = abstractLocationForDisplayInMGRS.toGeoString(GEO_MGRS);
dc.drawText(5, 50, Gfx.FONT_MEDIUM, mgrsStr, Gfx.TEXT_JUSTIFY_LEFT);

//this works, but displays in lat/long degree format.
var latStr = abstractLocation[0].toString();
var lonStr = abstractLocation[1].toString();
dc.drawText( 5, 50, Gfx.FONT_MEDIUM, latStr, Gfx.TEXT_JUSTIFY_LEFT );
dc.drawText( 5, 70, Gfx.FONT_MEDIUM, lonStr, Gfx.TEXT_JUSTIFY_LEFT );

// Note: I am NOT displaying my Current Location, so I am not using the
// Activity.getActivityInfo().currentLocation etc method...
}
  • no Idea on how you could create one, but maybe "steal" the one in info (currentLocation). (yes, it would be a hack) How to put your values in it, I don't know.

    I recall doing toGeoString() in a DF and dug up some old code (so it hasn't been tried lately).
    str=info.currentLocation.toGeoString(3);

    IIRC (like I said this was many months ago), the problem was that the value used for toGeoString() is defined in Position and that caused the error, so instead of GEO_MGRS, I just used it's actual value. So in the above, 3 instead of GEO_MGRS.

    Tried it just now, and it runs (I did this back in the 1.1 SDK days, I think! :) )

    In a DF (on 1.x devices in particular) memory is tight, but you make have to do your own conversion from degrees to whatever...