09-30-2011 11:45 AM
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?
10-07-2011 01:39 PM
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
10-10-2011 06:10 AM
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.
10-13-2011 12:09 PM
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
10-18-2011 01:03 PM
Just to bring this full circle, please note the following findings with respect to MapImage:
http://www.blackberry.com/developers/docs/7.0.0api
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:
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
10-19-2011 11:55 PM
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?
04-19-2012 04:39 AM
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,