Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6989983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:17:10+00:00 2026-05-27T19:17:10+00:00

I am using mapField to create a custom map.I am using the code in

  • 0

I am using mapField to create a custom map.I am using the code in this link.
How to show more than one location in Blackberry MapField?.
But the map position is fixed. i am not able to drag the map as we can do in google maps or when we invoke the maps like

 public void execute(ReadOnlyCommandMetadata metadata, Object context) 
        {
            Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments());
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:17:11+00:00Added an answer on May 27, 2026 at 7:17 pm

    Here’s some code that should get you going on the correct path. I’ve taken it from a project of mine that had some special requirements, so there could be some remnants of that left in there inadvertently. There will be some undefined variables in there — they’re member variables that are declared in the class and should all start with an underscore. This is also part of a class that extends MapField, so you would have to create a custom map class and then use that rather than the default.

    protected boolean touchEvent(TouchEvent message) {
        boolean ret =  super.touchEvent(message);
    
        //mark that we're starting to interact
        if(message.getEvent() == TouchEvent.DOWN) {
            _startTouchTracking = true;
            _clicking = true;
    
            _touchX = message.getX(1);
            _touchY = message.getY(1);
    
        }
        //user is wanting to move the map
        else if(message.getEvent() == TouchEvent.MOVE) {
            int dx = _touchX - message.getX(1);
            int dy = _touchY - message.getY(1);
            _clicking = false;
            _touchX = message.getX(1);
            _touchY = message.getY(1);
    
            //perform checks to make sure we don't move outside of the map's range
            int lat = getLatitude() - dy*(int)MathUtilities.pow(2, (double)getZoom());
            if(lat < -9000000) {
                lat = -9000000;
            }
            else if (lat > 9000000) {
                lat = 9000000;
            }
            int lon = getLongitude() + dx*(int)MathUtilities.pow(2, (double)getZoom());
            if(lon < -18000000) {
                lon = -18000000;
            }
            else if (lon > 18000000) {
                lon = 18000000;
            }
    
            moveTo(lat, lon);
        }
        //if the person just touches and releases, we want to move to that spot
        else if (message.getEvent() == TouchEvent.UNCLICK && _clicking) {
            int dx = message.getX(1) - getWidth()/2;
            int dy = message.getY(1) - getHeight()/2;
            move(dx, dy);
            _clicking = false;
        }
        //touch has been released
        else if (message.getEvent() == TouchEvent.UP) {
            _startTouchTracking = false;
        }
        //we handled the click
        return true;
    }
    

    As said, this might need tweaking for your use, but in general should get you started. The MathUtilities.pow() calls were my way of coming up with an appropriate amount of motion depending on the zoom level.

    Edit for Comments

    Letting a Bitmap move with the map:

    protected Coordinates _bitmapCoordinates;
    protected Bitmap _bitmap;
    public YourMapField() {
        //we're going to put the bitmap at -38.43, 20.32
        _bitmapCoordinates = new Coordinates(-38.43, 20.32, 0.0);
        _bitmap = YOUR_CODE_TO_GET_THE_BITMAP;
    }
    
    protected void paint(Graphics g) {
        super.paint(g);
        XYPoint placeToPaintBitmap = new XYPoint();
        convertWorldToField(_bitmapCoordinates, placeToPaintBitmap);
    
        //perform a check here to make sure that field will be seen. This code would depend
        //on how you're painting the image. Just check the placeToPaintBitmap.x and placeToPaintBitmap.y
        //against 0 and the map's width and height, along with some adjustment for how you paint
        if(bitmap will be visible on the screen) {
    
            //The code I have here is drawing the bitmap from the top left of the image, but if
            //you need to draw from some other place you may have to offset the x and y 
            g.drawBitmap(placeToPaintBitmap.x, placeToPaintBitmap.y, _bitmap.getWidth(), _bitmap.getHeight(), 0, 0);
        }
    }
    

    I didn’t test any of that code, so it might be buggy but should give you the general idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi everyone I tried using the Custom MapField to show several loacations on map.
I can able to show one location using co ordinates or longtitude and latitude
Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
I want to display MapField on Storm on Full Screen and for this i
Using PHP I'd like to compare an actual ip address to part of one,
Using Rails 3.2.0 with haml and sass: I Would like to link an external
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
Using jQuery, one can easily find out whether a particular element is visible using
Using Xcode4.2.1, with a basic PhoneGap template based app. (I say template, but I
Using Rails 3.2.0.rc2 and ruby 1.9.3p0 In app/views/requests/_form.html.erb I have the following code for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.