From 16caa7b8dd4516265bde2fe9f89f5b55dbb139d8 Mon Sep 17 00:00:00 2001 From: damocov Date: Tue, 11 Oct 2016 07:14:09 +0100 Subject: [PATCH] Added OrdnanceSurvey Bing Layer for UK users. (#891) Add Bing OSGB to mobile and desktop sites. --- .../openlayers/client/layer/BingType.java | 41 +++++++++++++++++++ .../org/traccar/web/client/view/MapView.java | 2 + .../web/shared/model/UserSettings.java | 1 + src/main/webapp/m/js/traccar-mobile.js | 4 +- 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100755 src/main/java/org/gwtopenmaps/openlayers/client/layer/BingType.java diff --git a/src/main/java/org/gwtopenmaps/openlayers/client/layer/BingType.java b/src/main/java/org/gwtopenmaps/openlayers/client/layer/BingType.java new file mode 100755 index 00000000..6773dd85 --- /dev/null +++ b/src/main/java/org/gwtopenmaps/openlayers/client/layer/BingType.java @@ -0,0 +1,41 @@ +/** + * + * Copyright 2015 sourceforge. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.gwtopenmaps.openlayers.client.layer; + +/** + * + * @author Giuseppe La Scaleia - CNR IMAA geoSDI Group + * @email giuseppe.lascaleia@geosdi.org + */ +public enum BingType { + + ROAD("Road"), + HYBRID("AerialWithLabels"), + AERIAL("Aerial"), + ORDNANCESURVEY("ordnancesurvey"); + // + private String value; + + private BingType(String theValue) { + this.value = theValue; + } + + @Override + public String toString() { + return value.toString(); + } +} diff --git a/src/main/java/org/traccar/web/client/view/MapView.java b/src/main/java/org/traccar/web/client/view/MapView.java index 8cf876c0..0b1400bb 100644 --- a/src/main/java/org/traccar/web/client/view/MapView.java +++ b/src/main/java/org/traccar/web/client/view/MapView.java @@ -159,6 +159,8 @@ private Layer createMap(UserSettings.MapType mapType) { return new Bing(new BingOptions(mapType.getName(), ApplicationContext.getInstance().getApplicationSettings().getBingMapsKey(), BingType.ROAD)); case BING_HYBRID: return new Bing(new BingOptions(mapType.getName(), ApplicationContext.getInstance().getApplicationSettings().getBingMapsKey(), BingType.HYBRID)); + case BING_ORDNANCE_SURVEY: + return new Bing(new BingOptions(mapType.getName(), ApplicationContext.getInstance().getApplicationSettings().getBingMapsKey(), BingType.ORDNANCESURVEY)); case BING_AERIAL: return new Bing(new BingOptions(mapType.getName(), ApplicationContext.getInstance().getApplicationSettings().getBingMapsKey(), BingType.AERIAL)); case STAMEN_TONER: diff --git a/src/main/java/org/traccar/web/shared/model/UserSettings.java b/src/main/java/org/traccar/web/shared/model/UserSettings.java index cc64bd50..91fe4423 100644 --- a/src/main/java/org/traccar/web/shared/model/UserSettings.java +++ b/src/main/java/org/traccar/web/shared/model/UserSettings.java @@ -86,6 +86,7 @@ public enum MapType implements IsSerializable { BING_ROAD("Bing Road") { @Override public boolean isBing() { return true; } }, BING_HYBRID("Bing Hybrid") { @Override public boolean isBing() { return true; } }, BING_AERIAL("Bing Aerial") { @Override public boolean isBing() { return true; } }, + BING_ORDNANCE_SURVEY("Bing Ordnance Survey") { @Override public boolean isBing() { return true; } }, STAMEN_TONER("Stamen Toner"); final String name; diff --git a/src/main/webapp/m/js/traccar-mobile.js b/src/main/webapp/m/js/traccar-mobile.js index 8727cff2..47d98a66 100644 --- a/src/main/webapp/m/js/traccar-mobile.js +++ b/src/main/webapp/m/js/traccar-mobile.js @@ -334,6 +334,8 @@ myApp.onPageInit('map-screen', function(page) { style = 'AerialWithLabels'; } else if (appState.userSettings.mapType == "BING_AERIAL") { style = 'Aerial'; + } else if (appState.userSettings.mapType == "BING_ORDNANCE_SURVEY") { + style = 'ORDNANCESURVEY'; } layers.push(new ol.layer.Tile({ @@ -925,4 +927,4 @@ if (myApp.device.ios) { $$(window).resize(function () { $$('.panel-left').css({height: $$(window).height() + 'px'}); }).trigger('resize'); -} \ No newline at end of file +}