开发者

Reverse Geocoding using Blackberry 5.0 API example anyone?

开发者 https://www.devze.com 2023-01-19 23:12 出处:网络
So the blackberry documentation shows you the following code example: import net.rim.device.api.lbs.*;

So the blackberry documentation shows you the following code example:

import net.rim.device.api.lbs.*;
import javax.microedition.location.*;

public class myReverseGeocode
{
    private Thread reverse开发者_运维问答Geocode;

    public myReverseGeocode()
    {
        reverseGeocode = new Thread(thread);
        reverseGeocode.setPriority(Thread.MIN_PRIORITY);
        reverseGeocode.start();
    }

    Runnable thread = new Runnable()
    {
        public void run()
        {
            AddressInfo addrInfo = null;

            int latitude  = (int)(45.423488 * 100000);
            int longitude = (int)(-80.32480 * 100000);

            try
            {
                Landmark[] results = Locator.reverseGeocode
                 (latitude, longitude, Locator.ADDRESS );

                if ( results != null && results.length > 0 )
                    addrInfo = results[0].getAddressInfo();
            }
            catch ( LocatorException lex )
            {
            }
        }
    };
}

How do I use the above mentioned code to pass in dynamic longitude/latitude values in my main application?


Is this just a basic java question? You have to use the 'final' keyword, so that the values can be passed in to the anonymous class held by the local variable 'thread'

public myReverseGeocode(final double latArg, final double lonArg)
{
    Runnable thread = new Runnable()
    {
        public void run()
        {
            AddressInfo addrInfo = null;

            int latitude  = (int)(latArg * 100000);
            int longitude = (int)(lonArg * 100000);

            try
            {
                Landmark[] results = Locator.reverseGeocode
                 (latitude, longitude, Locator.ADDRESS );

                if ( results != null && results.length > 0 )
                    addrInfo = results[0].getAddressInfo();
            }
            catch ( LocatorException lex )
            {
            }
        }
    };
    reverseGeocode = new Thread(thread);
    reverseGeocode.setPriority(Thread.MIN_PRIORITY);
    reverseGeocode.start();

 }
0

精彩评论

暂无评论...
验证码 换一张
取 消