If you wish to review the whole program I have made it available here (4mb).
The main parts of the code are as follows:
GeoCoder class
- converts a street address into a longitude/latitude point.
- call getLocation method with a string representing the address.
- class uses Google Geocoder.
Refer to the Geocoder.java class file in the download for more information on how this works.
Main Class
- assigns an address from the first command line argument
address = args[0];
- calls the GeoCoder.getLocation method with Address String
location = Geocoder.getLocation(address).toString();
- creates a KML file using the location value returned by the GeoCoder class
final Kml kml = new Kml();
kml.createAndSetPlacemark()
.withName(address)
.withOpen(Boolean.TRUE)
.createAndSetPoint()
.addToCoordinates(location);
try {
kml.marshal(new File("HelloKml.kml"));
} catch (FileNotFoundException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
In the future I will expand on this application to provide more information in the KML.
