简体   繁体   中英

Using Java and any external libraries, how can I draw latitude/longitude points onto a graphical representation of the Earth?

I'm currently using the Java Map Projection Library (I was able to obtain the code used for the Applet from the author and modify it for use in a desktop application - not sure if he linked to that on his website yet) to draw a map of the Earth in an application. However, I want to take this a step further. I have a set of latitude/longitude points that I want to plot on this map - I just need to draw a circle at each point and perhaps some lines connecting the circles (points) on the map. However, as the user uses the built-in panning and zooming capabilities, the points need to be redrawn in the proper position. The best I have been able to achieve is maintaining the points when zooming, and even then the points get larger as you zoom in.

I'm totally open to switching libraries, however I really haven't found a library that can take care of drawing a world map, particularly onto a Swing component (it doesn't need to be that accurate, just show the various landmasses somewhat correctly) and also plotting additional points on top of that map and having them "stick" to various latitude/longitude coordinates.

I have looked at Google Earth and NASA WorldWind, however they are awfully heavy for my purposes (I don't need anything that detailed or accurate) and it doesn't seem that easy to allow for offline use and integrate the world image view into an existing application.

Suggestions or thoughts?

You might take a look at other components of the www.osgeo.org Java stack. One of them is geotools: http://geotools.codehaus.org/

they is also development going on to create a GUI: http://geotools.codehaus.org/GUI+Architecture

While I haven't used it, the SwingLabs SwingX-WS project has a "rich map viewer component." There's a tutorial for getting started with the map component on the Java.net page.

Dealing with geospatial data can get VERY tricky quickly. What approach to take depends a lot on how accurate you need to be when displaying the data. GIS for Web Developers is a great book that covers the issues with geospatial data and how to get it from the data source onto the display. It is geared to web-based displays, but the concepts are the same.

If you do not need a high degree of accuracy a simple approach is to find an unprojected base map. With a base map it is easy to display lat/long points using simple Cartesian coordinates.

If you do need an accurate display then there really isn't a way to avoid the pretty complex libraries. There is a LOT of math involved in converting geospatial data with different datums and projections into something that can be displayed to users.

You should look at OpenMap .

We have been using OpenMap to display GPS tracks in desktop applications for a few years. Its really pretty easy to add your own layers for the track points, history, annotations, and your own data sources. You don't need to have any external connections if you don't want it to have them.

I looked quickly at GeoTools, but it seemed like getting started, at least a year or two ago was more complex than what we had already accomplished with OpenMap. We've been recently exploring WorldWind , but it definitely way more that we needed. OpenMap requires little in horsepower versus WorldWind which needs pretty decent video card.

I used OpenMap for an little app some time back - it's a hack, but shows how to do it. The app shows hurricane tracks from various years using data from NOAA. You can download it from here:

http://github.com/DonBranson/SnarfNOAA

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM