Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
New Developer
Posts: 11
Registered: ‎04-15-2009
My Device: Not Specified
Accepted Solution

Invoking Maps question regardng the XML

I am just putting the final touches on my app when I see something strange:

 

Page 17 (of the GPS and BlackBerry Maps Development Guide) has an XML call to Maps structures with a "<lbs>" wrapper, while starting page 19 it's "<location-document>"

 

Either way, my code is not working. I get a "Number Format Exception" which is baffling me. I'm running a 8330 simulator. 

Note: if I do not include the string document, I get the Map but with the default location.I'm assuming the issue is with the document XML.

 

Here is my string code: 

 

String document = "<location-document><location lon=\"" +
                        dataset.elementAt(i+3) + "\" lat=\"" +
                        dataset.elementAt(i+2) + "\" label=\""+
                        temp + "\" description=\"" +
                        temp + "\" zoom=\"4\" /></location-document>";

 

Here is my Invoke code:

 

Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments( MapsArguments.ARG_LOCATION_DOCUMENT, document));

 

This is what I trace in the console:

 

<location-document><location lon="-80.52070" lat="43.46310" label="New" description="New" zoom="4" /></location-document>

 

 Any help would be very appreciated! Thank you.

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: Invoking Maps question regardng the XML

Cross check with the document, the lon, lat, etc should be in single quote or double quote.

Use Search. "Accept Solution" If the problem is resolved.
New Developer
Posts: 11
Registered: ‎04-15-2009
My Device: Not Specified

Re: Invoking Maps question regardng the XML

I used singe and double quotes in the XML. Both did not work.
Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: Invoking Maps question regardng the XML

Remove the period(.)

 

lon="-80.52070" lat="43.46310" to lon="-8052070" lat="4346310"


Use Search. "Accept Solution" If the problem is resolved.
New Developer
Posts: 11
Registered: ‎04-15-2009
My Device: Not Specified

Re: Invoking Maps question regardng the XML

Thank you very much for pointing out what is embarrassingly obvious to me now that you've shown me the error. Smiley Happy

 

For others, I will include the code I used to convert from an object to a double to a int to a string:

 

// I had an object to start with, then I convert that to a double, then multiply that by 100000, then convert to int (to round it)

int templat =  (int)(Double.valueOf( dataset.elementAt(i+2).toString() ).doubleValue() * 100000);

int templon = (int)(Double.valueOf( dataset.elementAt(i+3).toString() ).doubleValue() * 100000);

 

// Make the string, and be sure to include a label and description so the Maps will not complain                    

String document = "<location-document><location lon=\"" + templon + "\" lat=\"" + templat + "\" label=\""+ temp + "\" description=\"" + temp + "\" zoom=\"4\" /></location-document>";

 

// Trace it make sure everything is fine

System.out.println("document trace :::::::::::::::::::::::::::::::::::::::::::::::: " + document);

 

// Invoke here, putting in the document you made above

Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments( MapsArguments.ARG_LOCATION_DOCUMENT, document));