vitalidze / traccar-web

Traccar Web UI mod
http://traccar.litvak.su/
151 stars 145 forks source link

How to add an Api key to create a layer #1087

Open Tabascool opened 7 years ago

Tabascool commented 7 years ago

Hi,

I added news maps and, like Stamen, i'd like to insert the Api key in the global setting. In the MapView.java, i create the function : private static native JSObject createNewMapLayer(String type, String key) /*-{ return new $wnd.OpenLayers.Layer.NewMap(type,key); }-*/; My problem is i don't know how to get the variable "key" in my "tile.NewMap.js". My method is possible?

Regard.

vitalidze commented 7 years ago

I think it should be possible, but it is out of scope of this project. You need to figure out how to handle this in plain JavaScript with OpenLayers library (v2), maybe ask on stackoverflow or something like this. After that it should be pretty straightforward to use this JavaScript code in Traccar Web UI Mod project.

Tabascool commented 7 years ago

Okay thank you. I think i'll use a method to call the java class in the Javascript to get the Api String variable. I think it should be possible.

vitalidze commented 7 years ago

Yes, it's definitely possible with currently exposed API. Mobile version is written in JavaScript and is always using that API.