LWUIT引路蜂地图开发示例:IP地址查询
IP地址查询,可以根据IP地址查询到该IP所在的地理经纬度坐标,比如下述例子查询IP 地址58.192.32.1,所在经纬度为118.777802,32.061699,为南京大学所在地。
[java]
package com.pstreets.gisengine.demo.lwuit;  
   
//--------------------------------- IMPORTS ------------------------------------   
   
import com.mapdigit.gis.DigitalMap;  
import com.mapdigit.gis.MapPoint;  
   
import com.mapdigit.gis.geometry.GeoLatLng;  
import com.mapdigit.gis.raster.MapType;  
import com.mapdigit.gis.service.IIpAddressGeocodingListener;  
   
import com.mapdigit.gis.service.IpAddressLocation;  
import com.pstreets.gisengine.demo.MapDemoLWUIT;  
import com.sun.lwuit.Command;  
import com.sun.lwuit.events.ActionEvent;  
   
public class MapIpSearchLWUIT extends MapDemoLWUIT  
        implements IIpAddressGeocodingListener{  
   
    private Command mapFindAddressCommand;  
   
    public void startApp() {  
        init();  
        canvas.setTitle("IP Search");  
   
        mapFindAddressCommand=new Command("Find Address"){  
            public void actionPerformed(ActionEvent evt) {  
                 map.getIpLocations("58.192.32.1");  
   
            }  
        };  
        canvas.addCommand(mapFindAddressCommand);  
        GeoLatLng center =  new GeoLatLng(32.0616667, 118.7777778);  
        map.setCenter(center, 13, MapType.MICROSOFTCHINA);  
        map.setIpAddressGeocodingListener(this);  
   
        canvas.show();  
    }  
   
    public void done(String query, IpAddressLocation result) {  
        if (result != null && result.error.length() == 0 
                && result.longitude.length() > 0 
                && result.latitude.length() > 0) {  
            try {  
   
                MapPoint mapPoint = new MapPoint();  
                String latLng = "[" + result.longitude + "," 
                        + result.latitude + ",0]";  
                mapPoint.point = DigitalMap.fromStringToLatLng(latLng);  
      &n
	
- 发表评论
- 
				
- 最新评论 进入详细评论页>>

![cocos2d_x+lua[2]](/uploads/allimg/131030/110J64609-0-lp.jpg)








