ULCXMapViewer

Purpose

Now you can see your house from above even with ULC!

This extension enables you to display various maps of different kinds (e.g. street maps, satellite maps, game maps) which are available on the Internet, e.g. Google Maps, Yahoo Maps, NASA World Wind, World of Warcraft and so forth. Basically, every map server that provides tile based maps can be accessed.

Please be aware of the terms and conditions imposed by the map providers. Sometimes they do not allow you to access the map tiles directly (which is the case with this extension), but only through their provided API, such as Google Maps. Yet it is technically feasible to access such map servers by this extension.

Screenshots

jfreechartextensionII_1

Features

Features of the extension

  • Implements the zooming and panning handling of JXMapViewer: Use the mouse wheel on the map in order to zoom in and out or press and drag the mouse button on the map in order to pan the map segment.
  • Supports the geo position handling of JXMapViewer: Indicate a geo position with a longitude/latitude pair and it will automatically be matched to the corresponding x/y coordinate of the map tile. Of course, the default mechanism can be overriden in order to support map servers with special tile addressing.
  • Extended API: The shift() method causes the map to be shifted towards one of the four directions.
  • Extended API: An IZoomChangedListener can be registered to the map component in order to be notified about zoom level changes.

Features of the sample application

  • Zoom the map by using either the mouse wheel or the provided zoom buttons. Activate or deactivate the mouse zooming.
  • Pan the map segment by using either the mouse drag mechanism or the provided pan buttons. Activate or deactive the mouse panning.
  • Enable high resolution city maps (only with NASA World Wind and only for these US cities) and zoom in until you see the cars in the streets!
  • Jump to predefined city locations.
  • Select between two different map sources.

How to use

A sample usage of ULCXMapViewer is provided in com.canoo.ulc.community.ulcxmapviewer.server.ULCXMapViewerSampleApplication.

ULCXMapViewer is simply an ULCComponent wrapping a JXMapViewer object on the client-side. Thus the first step is to instantiate an ULCXMapViewer object and to set the map's tile factory as well as the tile provider info. The tile provider info constructor requires the server access and map tiles properties.

...

ULCXMapViewer map = new ULCXMapViewer(); ULCDefaultTileFactory tileFactory = new ULCDefaultTileFactory(new ULCTileProviderInfo(MIN_ZOOM, MAX_ZOOM, TOTAL_ZOOM, TILE_SIZE, true, true, MAP_SERVER_URL, "x", "y", "z")); map.setTileFactory(tileFactory);

...

Now additional operations can be performed on the map viewer object, such as enabling mouse zooming/panning, setting the zoom level and the map's address location so that the map shows the correct location after being loaded.

...

map.setZoomEnabled(true); map.setZoom(3); map.setAddressLocation(new GeoPosition(35.333, -122.478));

...

The IZoomChangedListener can be easily added to the map viewer. It gets notified after the zoom level of the map viewer has been changed.

...

map.addZoomChangedListener(new IZoomChangedListener() { public void zoomChanged(ZoomChangedEvent event) { System.out.println("latest zoom level: " + event.getZoom()); } });

...

Resources