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

Trusted Contributor
Posts: 176
Registered: ‎04-12-2012
My Device: Bold 9780 & Curve 8250
My Carrier: vodacom
Accepted Solution

Adding a Image to the Map

Hi everyone 


What I want to do... Access the blackberry maps and add in an Image at users specified location if the User does not   

specify the Location then find the current location of the customer and add the image to those coordinates...

if you take a look at the following link I would like the mapview to be exactly the same...



for now I am not worried getting the coordinates of the address the user supplies and adding in the image to those coordinates, at the moment if i can get the "find my location"Function working correctly with adding the image at the correct coordinates il be very happy.


What my code is currently doing is adding two maps... the one map looks like the one in the following link:



But Has no Image, then when You click back another map appears that is zoomed out as far as one to be viewing countries with the Icon popping up.


My CodeSmiley SadMainScreen)

lat = qualifiedCoordinates.getLatitude();
lng = qualifiedCoordinates.getLongitude();

latString = Double.toString(lat);

lngstring = Double.toString(lng);
String Test2=".";
String Test3="";
FinalSringLatetude =replace(latString,Test2,Test3);
FinalSringLongdetude =replace(lngstring,Test2,Test3);
intLat = Integer.valueOf(FinalSringLatetude).intValue();
iintLng = Integer.valueOf(FinalSringLongdetude).intValue();

mCoordinates = new Coordinates(doublelat, doublelon, 0);
mMapField = new CustomMapField();
mMapField.mIcon = Bitmap.getBitmapResource("coin_silver.png");
MapView mapView = new MapView();
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments(mapView));



(custom MapField Class)

Bitmap mIcon;
XYRect mDest;

public void moveTo(Coordinates coordinates) {
mDest = null;

protected void paint(Graphics graphics) {
if (null != mIcon) {
if (null == mDest) {
XYPoint fieldOut = new XYPoint();
convertWorldToField(getCoordinates(), fieldOut);
int imgW = mIcon.getWidth();
int imgH = mIcon.getHeight();
mDest = new XYRect(fieldOut.x - imgW / 2,
fieldOut.y - imgH, imgW, imgH);
graphics.drawBitmap(mDest, mIcon, 0, 0);


thank you guys!!




Trusted Contributor
Posts: 176
Registered: ‎04-12-2012
My Device: Bold 9780 & Curve 8250
My Carrier: vodacom

Re: Adding a Image to the Map



Did the Trick