0

我想将谷歌地图集成到我的黑莓本机应用程序中。我的要求是:

  1. 搜索最近的位置
  2. 在地图上固定位置
  3. 点击任何引脚,将显示一个小弹出窗口,用户可以在其中查看详细说明
  4. 显示地址的工具提示应该是交互式的。

类似于附加图像的东西。用样本指导我实现它。

在此处输入图像描述

4

1 回答 1

0

您可以使用 GMLocation 位置示例

GMLocation location = new GMLocation(51.507778, -0.128056, "London");
invokeGMaps(location);

调用GMaps 方法

public void invokeGMaps(GMLocation l) {
        int mh = CodeModuleManager.getModuleHandle("GoogleMaps");
        if (mh == 0) {
            try {
                throw new ApplicationManagerException("GoogleMaps isn't installed");
            } catch (ApplicationManagerException e) {
                System.out.println(e.getMessage());
            }
        }
        RichTextField rich = new RichTextField("fhfdjdytdytd"+ mh);
        add(rich);
        URLEncodedPostData uepd = new URLEncodedPostData(null, false);
        uepd.append("action", "LOCN");
        uepd.append("a", "@latlon:" + l.getLatitude() + "," + l.getLongitude());
        uepd.append("title", l.getName());
        uepd.append("description", l.getDescription());

        String[] args = { "http://gmm/x?" + uepd.toString() };
        RichTextField rich1 = new RichTextField("l.getName()"+ l.getName());
        add(rich1);
        ApplicationDescriptor ad = CodeModuleManager.getApplicationDescriptors(mh)[0];
        ApplicationDescriptor ad2 = new ApplicationDescriptor(ad, args);
        try {
            ApplicationManager.getApplicationManager().runApplication(ad2, true);
        } catch (ApplicationManagerException e) {
            System.out.println(e.getMessage());
        }
    }

GMLocation 类

public class GMLocation {    
String mName;
String mDescription;
double mLatitude;
double mLongitude;
public GMLocation(double lat, double lon) {
    mLatitude = lat;
    mLongitude = lon;
}    
public GMLocation(double d, double e, String name) {
    this(d, e);
    mName = name;
}    
public GMLocation(double lat, double lon, String name, String descr) {
    this(lat, lon, name);
    mDescription = descr;
}    
public String getName() {
    return mName;
}    
public String getDescription() {
    return mDescription;
}    
public String getLongitude() {
    return String.valueOf(mLongitude);
}    
public String getLatitude() {
    return String.valueOf(mLatitude);
}

}

于 2012-05-04T07:33:19.727 回答