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
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...

http://stackoverflow.com/questions/1524428/how-to-show-our-own-icon-in-blackberry-map

 

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:

http://stackoverflow.com/questions/1524428/how-to-show-our-own-icon-in-blackberry-map

 

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");
mMapField.moveTo(mCoordinates);
MapView mapView = new MapView();
mapView.setLatitude(intLat);
mapView.setLongitude(iintLng);
mapView.setZoom(10);
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments(mapView));

add(mMapField);

 

(custom MapField Class)

Bitmap mIcon;
XYRect mDest;

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

protected void paint(Graphics graphics) {
super.paint(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!!

 

 

 

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

Re: Adding a Image to the Map

mMapField.setZoom(6);

 

Did the Trick