From f8280619a39cd05106b58b7198a99fd724d9b482 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 17 Dec 2016 20:39:57 +1300 Subject: Add support for Mozilla API key --- src/org/traccar/Context.java | 6 +++++- src/org/traccar/location/MozillaLocationProvider.java | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index 03e4635b6..d859e91bb 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -242,7 +242,11 @@ public final class Context { switch (type) { case "mozilla": - locationProvider = new MozillaLocationProvider(); + if (key != null) { + locationProvider = new MozillaLocationProvider(key); + } else { + locationProvider = new MozillaLocationProvider(); + } break; default: locationProvider = new OpenCellIdLocationProvider(key); diff --git a/src/org/traccar/location/MozillaLocationProvider.java b/src/org/traccar/location/MozillaLocationProvider.java index 37040a95e..cbfc19550 100644 --- a/src/org/traccar/location/MozillaLocationProvider.java +++ b/src/org/traccar/location/MozillaLocationProvider.java @@ -25,15 +25,17 @@ import javax.json.JsonReader; public class MozillaLocationProvider extends BaseLocationProvider { + private static final String URL = "https://location.services.mozilla.com/v1/geolocate"; + private String url; private String template; public MozillaLocationProvider() { - this("https://location.services.mozilla.com/v1/geolocate", "test"); + this("test"); } - public MozillaLocationProvider(String url, String key) { - this.url = url + "?key=" + key; + public MozillaLocationProvider(String key) { + this.url = URL + "?key=" + key; template = new StringBuilder() .append("{\"cellTowers\":[{") -- cgit v1.2.3