有人使用 Blackberry 5.0 API 进行反向地理编码示例吗?

发布于 2024-09-26 18:14:39 字数 1023 浏览 2 评论 0原文

因此,黑莓文档向您展示了以下代码示例:

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

public class myReverseGeocode
{
    private Thread reverseGeocode;

    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 )
            {
            }
        }
    };
}

如何使用上述代码在我的主应用程序中传递动态经度/纬度值?

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 reverseGeocode;

    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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤独难免 2024-10-03 18:14:39

这只是一个基本的java问题吗?您必须使用“final”关键字,以便可以将值传递给局部变量“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();

 }

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();

 }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文