BlackBerry Guide Bee Map Development example: IP address query

Source: Internet
Author: User

IP address query, you can query the IP address according to the geographical latitude and longitude coordinates, such as the following example query IP address 58.192.32.1, latitude and longitude of 118.777802, 32.061699, is the location of Nanjing University.

---------------------------------Package------------------------------------Package
Com.pstreets.gisengine.demo.rim; ---------------------------------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.MapDemoRIM;
Import Net.rim.device.api.ui.component.Menu;
Import Net.rim.device.api.ui.MenuItem; [------------------------------MAIN class----------------------------------] public class Mapipsearchrim extends Mapdemorim implements Iipaddressgeocodinglistener {/** * Entry point for application * @param args Comm  and line arguments (not used) */public static void main (string[] args) {//Create a new instance of The application and make the currently
        Running thread the application ' s event dispatch thread.
        Mapipsearchrim Theapp = new Mapipsearchrim ();
    Theapp.entereventdispatcher ();
           } private MenuItem Mapfindaddressmenuitem = new MenuItem ("Find Address", 0, 0) {public void run () {
        Map.getiplocations ("58.192.32.1");
    }
    };
        Public Mapipsearchrim () {init ();
        Pushscreen (canvas);
       Map.setipaddressgeocodinglistener (this);
        GEOLATLNG Center = new GEOLATLNG (32.0616667, 118.7777778); 
    Map.setcenter (center, Maptype.microsoftchina); The public void is 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);
                Mappoint.setname (result.organization);
                Mappoint.setnote (result.city + "" + result.country);
            Map.panto (Mappoint.point);
            } catch (Exception e) {result.error = "ip_not_found";
   }}} protected void CreateMenu (Menu menu, int instance) {menu.add (Mapfindaddressmenuitem); }
}

Note: The current IP query results are always returned in English, such as the above results in detail.
ISP: "China Education and the China Network"
Organization: "Nan Jing University"
Country: "CN"
City: "Nanjing"
If you want to know the latitude and longitude corresponding to the place name, you can use the address anti-coding service.
You can enter 127.0.0.1 to query the native address.

BlackBerry Guide Bee Map Development Kit Ver2.1 Download


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.