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
Regular Contributor
Posts: 64
Registered: ‎09-21-2011
My Device: Curve & 8520
My Carrier: TMN

MapImage

I want to customize the Map locations with my onw images. I am using the following code:

 

 Bitmap example = Bitmap.getBitmapResource("rss_icon.png");
 MapImage mapImage1 = new MapImage(48.727096,9.113503, example);

 

When I start my APP and opened the MAP, instead of my image appear the default image of the operative system. So, for some reason my image is not loaded. I has the image added to the resources folder and when I did debug all seems to be ok.

 

If I use the URI constructor the image appear correctly:

 

   MapImage mapImage2 = new MapImage(48.719735,9.132128, "http://i20.photobucket.com/albums      /b210/DKW1985/JCicons/Versus_icon2.gif");

 

But I want to use the local image. Any idea why this happens?

Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: MapImage

Hello nunonobre,

 

When you say resources folder, are you referring to the res sub-folder of your project? If so, can you attempt referencing your file as so:

 

Bitmap example = Bitmap.getBitmapResource("res/rss_icon.png");

 Also, when you debug your application, can you confirm that after executing the above line, example is not null and references a valid Object?

 

Erik Oros

BlackBerry Development Advisor


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Regular Contributor
Posts: 64
Registered: ‎09-21-2011
My Device: Curve & 8520
My Carrier: TMN

Re: MapImage

Yes, I'am refering the res sub-folder of my project. But, for example if I do something like

 

       Bitmap example  = Bitmap.getBitmapResource("rss_icon.png");
        BitmapField helloBmpField = new BitmapField(example);
        add(helloBmpField);

 

The Bitmap is shown in screen..no problem..

 

But If I use the same Bitmap in maps like:

 

Bitmap example = Bitmap.getBitmapResource("rss_icon.png");
MapImage mapImage1 = new MapImage(48.727096,9.113503, example);

 

The image doesn't appear in the MAP (just the default image..). For some reason it could not load the Bitmap in the MAP (I don't know why). When I did debug the example is not null and seems to be ok.

 

My third option was use the construtor that receives an URI (like the following)

 

MapImage mapImage2 = new MapImage(48.719735,9.132128, "http://i20.photobucket.com/albums      /b210/DKW1985/JCicons/Versus_icon2.gif");

 

It works without problem and the image is loaded in screen. But I want to use local images and use an URI like file://res/img/rss_icon.png...but it not works at all..I have already tried to use other formats like local// or cod//:  but nothing works.

 

 

 

Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: MapImage

Based on your description, I will admit that it's not clear why this issue is occurring. Would you be able to email into devsupport@rim.com, referencing this forum thread, and provide a zipped sample project that displays this behaviour? If I can reproduce this, it may warrant a bug report being logged.

 

Erik Oros

BlackBerry Development Advisor


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Highlighted
Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: MapImage

Just to bring this full circle, please note the following findings with respect to MapImage:

http://www.blackberry.com/developers/docs/7.0.0api/net/rim/device/api/lbs/maps/model/MapImage.html

 

In order to render a custom image on top of a MapField, you can use the iconUri constructor to reference a specific resource within your application:

http://www.blackberry.com/developers/docs/7.0.0api/net/rim/device/api/lbs/maps/model/MapImage.html#M...

 

The key is the way in which the String URI is created. To access, for instance, an image stored within your res/img folder, the following is an example of using the constructor with URI:

MapImage mi = new MapImage(43.483816, -80.53771, "res://img/icon.png");

 

If you're curious, the above location points at Waterloo, ON.

 

If you use the Bitmap constructor instead, this will simply render the default pin image on the MapField, however when the item is selected and expanded, you will see your full image at that time.

 

Erik Oros

BlackBerry Development Advisor


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
New Contributor
Posts: 6
Registered: ‎09-26-2011
My Device: BB 930
My Carrier: AT&T

Re: MapImage

Great! It worked with using "res" prefix. Another question -- is there a way to make custom icons with active fields in them? I looked at GasBuddy and they have a great map view -- the gas prices are displayed right in the icon. 

 

Can someone please describe how that can be acheived? 

Trusted Contributor
Posts: 103
Registered: ‎11-07-2010
My Device: Not Specified

Re: MapImage

Hello oros,

 

can we change the click event on this mapImage to make custom event; say as displaying a screen from my application.

 

namely, I want to handle the click event on maplocation or map image with my own handling, not the system handling.

 

is this applicable ?

 

thanks,