灯火互联
管理员
管理员
  • 注册日期2011-07-27
  • 发帖数41778
  • QQ
  • 火币41290枚
  • 粉丝1086
  • 关注100
  • 终身成就奖
  • 最爱沙发
  • 忠实会员
  • 灌水天才奖
  • 贴图大师奖
  • 原创先锋奖
  • 特殊贡献奖
  • 宣传大使奖
  • 优秀斑竹奖
  • 社区明星
阅读:3201回复:0

Java ME引路蜂地图开发示例:本地查询

楼主#
更多 发布于:2012-09-08 09:47


本地查询可以查询指定区域内诸如宾馆,邮局等用户感兴趣的地方。其使用方法和地址查询非常类似。
下面示例查询32.0616667, 118.7777778为中心点一定区域内宾馆的信息。
[java]
//--------------------------------- PACKAGE ------------------------------------  
package com.pstreets.gisengine.demo.midp;
  
//--------------------------------- IMPORTS ------------------------------------  
import com.mapdigit.gis.MapPoint;
import com.mapdigit.gis.geometry.GeoLatLng;
import com.mapdigit.gis.raster.MapType;
import com.mapdigit.gis.service.IGeocodingListener;
import com.pstreets.gisengine.demo.MapDemoMIDP;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
  
//[------------------------------ MAIN CLASS ----------------------------------]  
//--------------------------------- REVISIONS ----------------------------------  
// Date       Name                 Tracking #         Description  
// --------   -------------------  -------------      --------------------------  
// 28JAN2011  James Shen                              Initial Creation  
////////////////////////////////////////////////////////////////////////////////  
/**
*  map pan demo for Guidebee Map API on MIDP platform.
*/
public class MapLocalSearchMIDP extends MapDemoMIDP implements CommandListener,
        IGeocodingListener {
  
    private Command mapFindAddressCommand = new Command("Find Address",
            Command.OK, 1);
  
    public void startApp() {
  
        init();
        canvas.addCommand(mapFindAddressCommand);
        map.setGeocodingListener(this);
        canvas.setCommandListener(this);
        GeoLatLng center = new GeoLatLng(32.0616667, 118.7777778);
        map.setCenter(center, 13, MapType.MICROSOFTCHINA);
        Display.getDisplay(this).setCurrent(canvas);
    }
  
    public void commandAction(Command c, Displayable d) {
        if (c == mapFindAddressCommand) {
            String name = "??";
                GeoLatLng screenCenter = map.getScreenCenter();
                map.getLocations(name, 0, screenCenter,
                        map.getScreenBounds(screenCenter));
        }
    }
  
    public void done(String query, MapPoint[] result) {
        if (result != null) {
            map.panTo(result[0].getPoint());
            for (int i = 0; i < result.length; i++) {
                System.out.println(result.objectNote);
            }
        }
    }
}
//--------------------------------- PACKAGE ------------------------------------
package com.pstreets.gisengine.demo.midp;

//--------------------------------- IMPORTS ------------------------------------
import com.mapdigit.gis.MapPoint;
import com.mapdigit.gis.geometry.GeoLatLng;
import com.mapdigit.gis.raster.MapType;
import com.mapdigit.gis.service.IGeocodingListener;
import com.pstreets.gisengine.demo.MapDemoMIDP;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;

//[------------------------------ MAIN CLASS ----------------------------------]
//--------------------------------- REVISIONS ----------------------------------
// Date       Name                 Tracking #         Description
// --------   -------------------  -------------      --------------------------
// 28JAN2011  James Shen                              Initial Creation
////////////////////////////////////////////////////////////////////////////////
/**
*  map pan demo for Guidebee Map API on MIDP platform.
*/
public class MapLocalSearchMIDP extends MapDemoMIDP implements CommandListener,
        IGeocodingListener {

    private Command mapFindAddressCommand = new Command("Find Address",
            Command.OK, 1);

    public void startApp() {

        init();
        canvas.addCommand(mapFindAddressCommand);
        map.setGeocodingListener(this);
        canvas.setCommandListener(this);
        GeoLatLng center = new GeoLatLng(32.0616667, 118.7777778);
        map.setCenter(center, 13, MapType.MICROSOFTCHINA);
        Display.getDisplay(this).setCurrent(canvas);
    }

    public void commandAction(Command c, Displayable d) {
        if (c == mapFindAddressCommand) {
            String name = "??";
                GeoLatLng screenCenter = map.getScreenCenter();
                map.getLocations(name, 0, screenCenter,
                        map.getScreenBounds(screenCenter));
        }
    }

    public void done(String query, MapPoint[] result) {
        if (result != null) {
            map.panTo(result[0].getPoint());
            for (int i = 0; i < result.length; i++) {
                System.out.println(result.objectNote);
            }
        }
    }
}
本地查询方法
public void getLocations(String address,int start,GeoLatLng center,GeoBounds bound, IGeocodingListener listener);
指定中心点和查询区域。本地查询可以多次返回结果,start为查询结果起始顺序,每次返回结果在SearchOptions 中定义,缺省每次返回4个。  www.atcpu.com
上述结果返回内容为,具体结果可能不同。
“晶丽酒店025-83310818 025-83310818212223 025-86636636 ”
“城市名人酒店025-83123333 025-83123888 ”
“南京玄武饭店 025-83358888 ”
“Sofitel Galaxy Nanjing – 南京索菲特银河大酒店025-83718888
作者:mapdigit

喜欢0 评分0
游客

返回顶部