Displaying KML overlays on a map
KML documents are XML-based documents that you can use to store geographic data about places, buildings, points of interest, cycle paths, pictures, and so on. You can create and publish a KML document to a web site. You can display the KML data in a map field by specifying the URL of the KML document in the MapFactory.populateDataModelFromKmlUrl(MapDataModel model, String url, String tag) method.
Your application can display KML data in a map field only if the KML document is retrieved through the BlackBerry Internet Service or the BlackBerry Enterprise Server (for example, a KML document that is stored on a web site or on an intranet site). A KML document that is stored on a BlackBerry device (for example, on a media card) cannot be displayed.
Code sample: Displaying a KML overlay
String officeTag = "RIM offices"; String officeUrl = "http://www.example.com/rim_offices.kml"; //create the map field RichMapField view = MapFactory.getInstance().generateRichMapField(); // retrieve the KML document and populate the data model MapDataModel model = view.getModel(); MapFactory.getInstance().populateDataModelFromKmlUrl( model, officeUrl, officeTag ); // display only the RIM offices and center the view on the visible locations model.setVisibleNone(); model.setVisible( officeTag ); view.getMapField().update( true );