Belongs to following categories: Integration, Extension, Graphic, ULC6.1, ULC6.2, UltraLightClient '08,
Project Home
Downloads
Purpose
Now you can see your house from above even with
ULC!
This contribution shows how
SwingX-WS's JXMapViewer, a free generic viewer for tile based
map servers, can be integrated into ULC applications. 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

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.
Resources
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());
}
});
...
Compatibility
- ULC 6.1: JDK 1.5, JDK 1.6, Windows XP
- ULC 6.2: JDK 1.5, JDK 1.6, Windows XP, Windows Vista, Mac OSX,
Linux
- UltraLightClient 2008: JDK 1.5, JDK 1.6, Windows XP, Windows
Vista, Mac OSX, Linux
JDK 1.5 on the client-side is a requirement as
SwingX-WS
does not run under JDK 1.4. The dependent libraries
swingx.jar
and
swingx-ws.jar are under ongoing development
and thus subject to potential API or implementation changes. For this
reason, the above-mentioned functionality cannot be guaranteed in any
circumstance.
Project setup with Eclipse
The project contains all necessary Eclipse project files and can be
directly imported from the repository. The classpath in this project
contains a entry named
ULC Library, which locates
the needed UltraLightClient libraries. For to uses the
ULC
Library entry you have to install the Eclipse Java IDE Integration
Plug-in that can be found at:
http://update.canoo.com/eclipse.
A installation guide how to install plug-ins in Eclipse can be found at
the Eclipse help pages: Workbench User Guide > Tasks > Updating and
installing software.
Project Links
Project Home
Downloads
Authors
marc.hermann