Open main menu

CDOT Wiki β

Changes

Teams Winter 2011/team1/BlackBerry/Add Mapping Option

544 bytes added, 14:45, 8 April 2011
no edit summary
{
Student student = (Student) _keywordFilterField.getSelectedElement();
if(student != null) { try { String address = student.getAddress(); //start coordinates Coordinates co = new Coordinates(45.423488, -75.697929, 0); Landmark[] landm = Locator.geocode showAddress(address, co); //Get latitude and longitude double lon = landm[0].getQualifiedCoordinates().getLongitude()*100000.0 ; double lat = landm[0].getQualifiedCoordinates().getLatitude()*100000.0; //create XML document StringBuffer document = new StringBuffer("<location-document><location lon='"); document.append(lon).append("' lat='").append(lat).append("' label='").append(address); document.append("' description='Student Address' zoom='10'/></location-document>"); // Invoke maps application for current Contact Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments(MapsArguments.ARG_LOCATION_DOCUMENT, document.toString())); } catch(LocatorException ex){ Dialog.alert("cannot get location: " + ex.getMessage()); } catch(Exception ex){ Dialog.alert("map application is not available: "+ ex.getMessage()); } }
}
})); </source>10.5. Implement <code>showAddress()</code> method: <source lang="java"> public void showAddress(String adrs)throws LocatorException{ final String address = adrs; new Thread(new Runnable(){ public void run(){ try{ Coordinates co = new Coordinates(45.423488, -75.697929, 0); Landmark[] landm = Locator.geocode(address, co); //Get latitude and longitude double lon = landm[0].getQualifiedCoordinates().getLongitude()*10000.0 ; double lat = landm[0].getQualifiedCoordinates().getLatitude()*10000.0; //create mapview MapView mapView = new MapView(); mapView.setLatitude((int)lat); mapView.setLongitude((int)lon); mapView.setZoom(10); // Invoke maps application for current Contact Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments(mapView)); } catch(LocatorException ex){ Dialog.alert("Cannot find location: " + ex.getMessage()); } catch(Exception ex){ Dialog.alert("Exception when getting location: " + ex.getMessage()); } } }).start(); }
</source>
1
edit