Java ME引路蜂地图开发示例:地址反编码

地址反编码是通过经纬度查询对应的地名,下面示例是查询经纬度为118.777802, 32.061699对应的地名,结果为”中国江苏省南京市鼓楼区渊声巷41号”。

注意使用字符串经纬度格式时,纬度在前,经度在后,如果反了,则返回的地名或能为空或都跑到外国去了。结果也是一个数组,一般到第一个结果,后面结果是更大的区域或是距离相对较远的地名。

//------------------------------------------------------------------------------ 
//                         COPYRIGHT 2011 GUIDEBEE 
//                           ALL RIGHTS RESERVED. 
//                     GUIDEBEE CONFIDENTIAL PROPRIETARY 
/ REVISIONS  
// Date       Name                 Tracking #         Description 
// ---------  -------------------  ----------         -------------------------- 
// 28JAN2011  James Shen                              Initial Creation 
 
//--------------------------------- 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.IReverseGeocodingListener; 
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. 
 * <hr><b>© Copyright 2011 Guidebee, Inc. All Rights Reserved.</b> 
 * @version     1.00, 28/01/11 
 * @author      Guidebee Pty Ltd. 
 */
public class MapReverseGeocodingMIDP extends MapDemoMIDP implements
        CommandListener, 
        IReverseGeocodingListener { 
  
    private Command mapFindAddressCommand = new Command("Find Address", 
            Command.OK, 1); 
  
    public void startApp() { 
  
        init(); 
        canvas.addCommand(mapFindAddressCommand); 
        map.setReverseGeocodingListener(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) { 
            map.getReverseLocations("32.061699,118.777802"); 
        } 
    } 
  
    public void done(String arg0, MapPoint[] result) { 
        if (result != null) { 
            map.panTo(result[0].getPoint()); 
        } 
    } 
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值