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

Web and WebWorks Development

Reply
Developer
confinedspace
Posts: 40
Registered: ‎04-16-2010
My Device: na
My Carrier: na
Accepted Solution

Multiple Points on Maps

Hello,

 

Anyone know how to plot multiple points on a map? I believe it's something to do with the blackberry.invoke.MapsArguments ( locationDocument : Document ) but I don't know how to use it. I've tried:

 

 

var document = "<location-document><location x='51.499874' y='-0.122223' label ='London' description='London UK' /><location x='54.975545' y='-1.61293' label ='Newcastle' description='Newcastle UK' /></location-document>";

var args = new blackberry.invoke.MapsArguments(document);
blackberry.invoke.invoke(blackberry.invoke.APP_MAPS, args);

 

 

I can plot an individual point with:

 

 

var args = new blackberry.invoke.MapsArguments(43.26, -80.30);
blackberry.invoke.invoke(blackberry.invoke.APP_MAPS, args);

 

 

Kind regards

 

Please use plain text.
Developer
swati-srivastava
Posts: 282
Registered: ‎02-25-2010
My Device: curve,bold,storm
My Carrier: Verizon,AT&T

Re: Multiple Points on Maps

[ Edited ]

 

String document1 ;
document1="<location-document>" +
"<location lon='"+longitude1+"' lat='"+Latitude1+"' label='1'/>"+
"<location lon='"+Longitude2+"' lat='"+Latitude2+"' label='2'/>"+
"<location lon='"+Longitude3+"' lat='"+Latitude3+"' label='3'/>"+
"<location lon='"+Longitude4+"' lat='"+Latitude4+"' label='4'/>"+ "</location-document>";


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

Passs the latitude and longitude values in 1,2,3,4

 hey i worked like this and it worked for me


 

Please use plain text.
Developer
confinedspace
Posts: 40
Registered: ‎04-16-2010
My Device: na
My Carrier: na

Re: Multiple Points on Maps

Thanks for the reply.

 

Isn't that the code for Java apps though? I'm making a widget, which is Javascript.

 

Kind regards.

Please use plain text.
Developer
confinedspace
Posts: 40
Registered: ‎04-16-2010
My Device: na
My Carrier: na

Re: Multiple Points on Maps

Also just tried:

 

 

var xmlString = "<location-document><location x='51.499874' y='-0.122223' label ='Lodon' description='London UK' /><location x='54.975545' y='-1.61293' label ='Newcastle' description='Newcastle UK' /></location-document>";

var parser = new DOMParser(); var doc = parser.parseFromString(xmlString, "text/xml"); var args = new blackberry.invoke.MapsArguments(doc); blackberry.invoke.invoke(blackberry.invoke.APP_MAPS, args);

 

 

But I get the error:

 

JVM Error 104

Uncaught:

NumberFormaException

Please use plain text.
Developer
confinedspace
Posts: 40
Registered: ‎04-16-2010
My Device: na
My Carrier: na

Re: Multiple Points on Maps

[ Edited ]

Anyone know if blackberry.invoke.MapsArguments ( locationDocument : Document ) works?

 

It's in the API: http://www.blackberry.com/developers/docs/widgetapi/

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Multiple Points on Maps

Hi confinedspace,

 

I saw this work just yesterday when an internal developer demo'd a little application that they had been working on.  I'll see if I can get their source code and post up a sample.  I believe the trick is in the formatting of the Document contents.

 

We don't do a very good job in describing this XML format and we are looking to improve our API documentation around this.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Developer
confinedspace
Posts: 40
Registered: ‎04-16-2010
My Device: na
My Carrier: na

Re: Multiple Points on Maps

[ Edited ]

Thanks Tim! I look forward to seeing the sample code.

 

Regards.

Please use plain text.
Developer
confinedspace
Posts: 40
Registered: ‎04-16-2010
My Device: na
My Carrier: na

Re: Multiple Points on Maps

[ Edited ]

I messed around with different XML structures and got this working:

 

 

var xmlString = '<?xml version="1.0"?><lbs clear="ALL" id="Wat"><location x="-8052237" y="4346518" label="Waterloo, ON" description="Waterloo" /><location lon="-7569792" lat="4542349" label="Ottawa, ON" description="Ottawa, Ontario, Canada" /></lbs>';

var parser = new DOMParser(); var doc = parser.parseFromString(xmlString, "text/xml"); var args = new blackberry.invoke.MapsArguments(doc); blackberry.invoke.invoke(blackberry.invoke.APP_MAPS, args);

 

REMEMBER: You have to multiply the coords by 100,000 (so 54.97781, -1.61396 is actually 5497781, -161396).

 

More info about the XML elements here: http://docs.blackberry.com/en/developers/deliverables/11944/XML_element_location_893142_11.jsp and http://docs.blackberry.com/en/developers/deliverables/11944/XML_element_lbs_893141_11.jsp

 

Thanks for pointing me in the right direction Tim!

 

Please use plain text.