BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-16-2010, 10:45 AM   #1 (permalink)
New Member
 
Join Date: Mar 2010
Model: 8220
PIN: N/A
Carrier: Rogers
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Mapfield and Layers

Please Login to Remove!

Hi all

I'm developing a small map-based app... basically a two-layered application when the bottom layer contains a Mapfield object, and where the top layer displays points, and other polygon shapes and lines for routes, zones, etc.

My question is my layer-based approach the best for this application? And if so how do i append the mapfield object (_mapfield) to the layer?

here's the api reference I'm trying to use:

blackberry.com/developers/docs/4.5.0api/javax/microedition/lcdui/game/LayerManager.html

Thanks again
Offline  
Old 03-25-2010, 12:29 PM   #2 (permalink)
New Member
 
Join Date: Mar 2010
Model: 8220
PIN: N/A
Carrier: Rogers
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem Solved!

Mapfield has a paint method that allows you to paint graphics onto the mapfield object. Thus, the layering method was not required, and it was possible to directly drop bitmap resource (i.e. image files, dots, etc.) directly onto the map.

I created a child class of Mapfield (i.e. class mod_map extends Mapfield) and declared the paint method as seen below. This method executes when the object is created, thus requires the vector object "_poi" to be passed into the constructor in the beginning itself.

I've attached my code below, and i beleive its pretty self explanatory. "red_marker" and "cursor" are .png resource i'm using to drop red points on the map




Code:
 public void paint (Graphics g)
    {
        super.paint(g);
            
        // Place a cursor permanently at the center of the map.
        int width = getPreferredWidth();
        int height = getPreferredHeight();
        g.drawBitmap((width/2), (height/2), width, height, cursor, 0, 0); 
        
           
    
        // Draw the POI's onto the map
        if ( _poi != null ) {
            for (int i = _poi.size() - 1 ; i >= 0  ; --i) {
                XYPoint temp_xy = new XYPoint();
                pointOfInterest temp = (pointOfInterest) _poi.elementAt(i);
                convertWorldToField(temp.lat_long, temp_xy);
                g.drawBitmap(temp_xy.x, temp_xy.y, width, height, red_marker, 0, 0); 
            }
       }
    }
Offline  
Old 03-25-2010, 03:35 PM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2010
Model: N/A
PIN: N/A
Carrier: Fledge
Posts: 43
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ed,

I apologize for not responding to this when you first posted it.

I was going to suggest the paint method (it is a field, after all) because I thought it would be easier but since I know nothing about game development or layers I thought it would be best for me to keep my mouth shut.
Offline  
Old 04-05-2010, 01:16 PM   #4 (permalink)
New Member
 
Join Date: Mar 2010
Model: 8220
PIN: N/A
Carrier: Rogers
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

no problem jacob. I'm at a point where i'm trying to paint zones and routes on the map based on some points... I'm not fairly certain how to approach this. If you have any input/good resources on this topic, it would be really appreciated. Thanks
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.