traccar-web
traccar-web copied to clipboard
Where to change the google map api key?
Hi, I went to change open lay map(google map) with my google map api, Where to change the code? I can't find https://github.com/tananaev/traccar/blob/master/src/org/traccar/geocode/GoogleReverseGeocoder.java to edit it.
Thanks.
This is the code of the backend project and it is actually related to the reverse geocoding. Here is where maps are initialized in this project: https://github.com/vitalidze/traccar-web/blob/dev/src/main/java/org/traccar/web/client/view/MapView.java#L131
Thank you, and which place i can add the api code. case GOOGLE_HYBRID: GoogleV3Options gHybridOptions = new GoogleV3Options(); gHybridOptions.setNumZoomLevels(20); gHybridOptions.setType(GoogleV3MapType.G_HYBRID_MAP); return new GoogleV3(mapType.getName(), gHybridOptions); case GOOGLE_NORMAL: GoogleV3Options gNormalOptions = new GoogleV3Options(); gNormalOptions.setNumZoomLevels(22); gNormalOptions.setType(GoogleV3MapType.G_NORMAL_MAP); return new GoogleV3(mapType.getName(), gNormalOptions); case GOOGLE_SATELLITE: GoogleV3Options gSatelliteOptions = new GoogleV3Options(); gSatelliteOptions.setNumZoomLevels(20); gSatelliteOptions.setType(GoogleV3MapType.G_SATELLITE_MAP); return new GoogleV3(mapType.getName(), gSatelliteOptions); case GOOGLE_TERRAIN: GoogleV3Options gTerrainOptions = new GoogleV3Options(); gTerrainOptions.setNumZoomLevels(16); gTerrainOptions.setType(GoogleV3MapType.G_TERRAIN_MAP); return new GoogleV3(mapType.getName(), gTerrainOptions);
Unfortunately I don't see a way to set up the API key for google maps. I need to make some further investigation, maybe it will be possible through JSNI, by calling some javascript code directly.
Is possible replace https://github.com/vitalidze/traccar-web/blob/dev/src/main/webapp/traccar.html#L25 with to make it work? Cause without api key , when select google map, it's display " Oops! Something went wrong. This page didn't load Google Maps correctly. See the JavaScript console for technical details."
Yes, according to the docs https://developers.google.com/maps/documentation/javascript/get-api-key?hl=en#premium-key this is the correct place to insert your API key. You can change it inside the traccar-web.war
file, which is actually a zip archive.
ok, Thank you very much.
Hello vitalidze , onethings I wolud like to ask you if you resolve the problem because I have the same problem
Oops! Something went wrong. This page didn't load Google Maps correctly. See the JavaScript console for technical details.
I wish you help me
regards
@Gfernandez Register google map Api key for your domain name or ip that you use for traccar. Then edit and place api key in https://github.com/vitalidze/traccar-web/blob/dev/src/main/webapp/traccar.html#L25 . Rebuild traccar-web.war file and replace in /opt/traccar/
@onethings Do we have to edit this line or add new line, as i tried adding < script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" type="text/javascript >< / script > below the above code, but it didnt work. Can you tell me the correct way of doiung it.
@shubhamalive you need to replace YOUR_API_KEY with your own google map api key in above URL. You can registrat your own google map api key at https://developers.google.com/maps/documentation/javascript/get-api-key?hl=en
@onethings i have registered and got my API, but how to use it, can you give me a sample URL
I have done it like this,
Rebuild traccar-web.war file and replace in /opt/traccar/
http://traccar.litvak.su/building.html
@onethings Thanks Mate. That worked :100: % :+1:
1.downloaded traccar-web.git, - 2.Change to the cloned repo folder????? - cd traccar-web. ?????? then I can't move
@mataier you can just unpack the traccar-web.war
, update traccar.html
and then pack it back. The traccar-web.war
is an ordinary zip-archive.
insert the key court (?)
this
<script src="js/openlayers/OpenStreetMap.js"></script>
<script src="//maps.google.com/maps/api/js(?)v=3"></script>
<script type="text/javascript" src="js/openseamap/harbours.js"></script>
<script type="text/javascript" src="js/openseamap/map_utils.js"></script>
<script type="text/javascript" src="js/stamen/tile.stamen.js"></script>
<script type="text/javascript" src="traccar/traccar.nocache.js"></script>
yes, thanks, that worked!!!!
how to add a map ArcGis?
@mataier first of all, please don't post such questions in this thread. It's not related with adding map providers.
To add a map you need to update code and rebuild project. See this commit for example of such changes: https://github.com/vitalidze/traccar-web/commit/f2642016545d4ae084b36ecb43e2cad7c0941234 Also this ticket may be of help: #699
Hii, When I used version 2.12,there was traccar-web.war file and traccar.html file .But in version 3.7 there is no war file.How and where i will set api key?
@sdip025 There must be a traccar-web.war
file if you followed installation instructions: http://traccar.litvak.su/installation.html
Otherwise you are using a standard web UI of traccar and all questions about it should go here: https://github.com/tananaev/traccar-web/issues
@shubhamalive you need to replace YOUR_API_KEY with your own google map api key in above URL. You can registrat your own google map api key at https://developers.google.com/maps/documentation/javascript/get-api-key?hl=en
hello, I tried the
Rebuild traccar-web.war file and replace in /opt/traccar/
http://traccar.litvak.su/building.html
Hello, I tried this recommendation, but it doesn`t Worked,