diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-01-27 13:52:23 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-01-27 13:52:23 +1300 |
commit | 611494b77c8906d3fe7fd02039c5ede323b1fde4 (patch) | |
tree | 88311a473ef153824dca79b5105d8612ad0bda0a | |
parent | 268ac2ad8dab34676631c7af23f9af3a7b3bc89b (diff) | |
download | trackermap-web-611494b77c8906d3fe7fd02039c5ede323b1fde4.tar.gz trackermap-web-611494b77c8906d3fe7fd02039c5ede323b1fde4.tar.bz2 trackermap-web-611494b77c8906d3fe7fd02039c5ede323b1fde4.zip |
Add more map layers
-rw-r--r-- | src/org/traccar/web/client/view/MapView.java | 40 | ||||
-rw-r--r-- | war/traccar.html | 1 |
2 files changed, 37 insertions, 4 deletions
diff --git a/src/org/traccar/web/client/view/MapView.java b/src/org/traccar/web/client/view/MapView.java index adc1a21a..f57ec653 100644 --- a/src/org/traccar/web/client/view/MapView.java +++ b/src/org/traccar/web/client/view/MapView.java @@ -22,8 +22,15 @@ import org.gwtopenmaps.openlayers.client.Map; import org.gwtopenmaps.openlayers.client.MapOptions; import org.gwtopenmaps.openlayers.client.MapWidget; import org.gwtopenmaps.openlayers.client.Projection; +import org.gwtopenmaps.openlayers.client.control.LayerSwitcher; import org.gwtopenmaps.openlayers.client.control.ScaleLine; import org.gwtopenmaps.openlayers.client.geometry.Point; +import org.gwtopenmaps.openlayers.client.layer.Bing; +import org.gwtopenmaps.openlayers.client.layer.BingOptions; +import org.gwtopenmaps.openlayers.client.layer.BingType; +import org.gwtopenmaps.openlayers.client.layer.GoogleV3; +import org.gwtopenmaps.openlayers.client.layer.GoogleV3MapType; +import org.gwtopenmaps.openlayers.client.layer.GoogleV3Options; import org.gwtopenmaps.openlayers.client.layer.Markers; import org.gwtopenmaps.openlayers.client.layer.MarkersOptions; import org.gwtopenmaps.openlayers.client.layer.OSM; @@ -74,6 +81,31 @@ public class MapView { point.transform(new Projection("EPSG:4326"), new Projection(map.getProjection())); return point; } + + private void initMapLayers(Map map) { + map.addLayer(OSM.Mapnik("OpenStreetMap")); + + GoogleV3Options gHybridOptions = new GoogleV3Options(); + gHybridOptions.setType(GoogleV3MapType.G_HYBRID_MAP); + map.addLayer(new GoogleV3("Google Hybrid", gHybridOptions)); + + GoogleV3Options gNormalOptions = new GoogleV3Options(); + gNormalOptions.setType(GoogleV3MapType.G_NORMAL_MAP); + map.addLayer(new GoogleV3("Google Normal", gNormalOptions)); + + GoogleV3Options gSatelliteOptions = new GoogleV3Options(); + gSatelliteOptions.setType(GoogleV3MapType.G_SATELLITE_MAP); + map.addLayer(new GoogleV3("Google Satellite", gSatelliteOptions)); + + GoogleV3Options gTerrainOptions = new GoogleV3Options(); + gTerrainOptions.setType(GoogleV3MapType.G_TERRAIN_MAP); + map.addLayer(new GoogleV3("Google Terrain", gTerrainOptions)); + + final String bingKey = "AseEs0DLJhLlTNoxbNXu7DGsnnH4UoWuGue7-irwKkE3fffaClwc9q_Mr6AyHY8F"; + map.addLayer(new Bing(new BingOptions("Bing Road", bingKey, BingType.ROAD))); + map.addLayer(new Bing(new BingOptions("Bing Hybrid", bingKey, BingType.HYBRID))); + map.addLayer(new Bing(new BingOptions("Bing Aerial", bingKey, BingType.AERIAL))); + } public MapView() { contentPanel = new ContentPanel(); @@ -85,18 +117,18 @@ public class MapView { mapWidget = new MapWidget("100%", "100%", defaultMapOptions); map = mapWidget.getMap(); - OSM mapLayer = OSM.Mapnik("Mapnik"); - mapLayer.setIsBaseLayer(true); - VectorOptions vectorOptions = new VectorOptions(); vectorLayer = new Vector("Vector", vectorOptions); MarkersOptions markersOptions = new MarkersOptions(); markerLayer = new Markers("Markers", markersOptions); - map.addLayer(mapLayer); + initMapLayers(map); + map.addLayer(vectorLayer); map.addLayer(markerLayer); + + map.addControl(new LayerSwitcher()); map.addControl(new ScaleLine()); map.setCenter(createLonLat(12.5, 41.9), 1); diff --git a/war/traccar.html b/war/traccar.html index 2278257e..1957a3e6 100644 --- a/war/traccar.html +++ b/war/traccar.html @@ -6,6 +6,7 @@ <link rel="stylesheet" type="text/css" href="traccar/reset.css" /> <script src="http://www.openlayers.org/api/OpenLayers.js"></script> <script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script> + <script src="http://maps.google.com/maps/api/js?v=3&sensor=false"></script> <script type="text/javascript" src="traccar/traccar.nocache.js"></script> </head> <body> |