Documentation Web Server

 

Google Maps API Key

When Google first released version 3 of Google Maps they let people use it without having to register for an API key.

In June 2016 Google rolled back on this position. Private use of Google Maps continues to work without an API key but public sites must use a key.

Sites that were up on the Internet before June 2016 will continue to work without an API key until October 2016. To continue working after October 2016 they will also need to use a key.

The effect on Virtual Radar Server

Google Maps will continue to work without an API key when you view Virtual Radar Server over a private network

This means that the majority of Virtual Radar Server users are unaffected because most users do not put their VRS instance onto the Internet.

If you were to look in the browser console you might see a warning saying that Google Maps was loaded without an API key but Maps will continue to work.

However, if you do put your Virtual Radar Server instance onto the Internet then, although it will continue to work over the private network, you will see something like this in place of the map when you access the site over the Internet:

Oops! Something went wrong. This page didn't load Google Maps correctly. See the JavaScript console for technical details.

You will need to obtain an API key from Google for your instance of Virtual Radar Server if you want to see the map when you access the site over the Internet.

How to obtain an API key

You will need to register with Google for an API key. At the time of writing you can register for the API key here:

https://developers.google.com/maps/documentation/javascript/get-api-key

You will need to sign in with your Google account (registering for one if you don't already have one) and then create a project.

Once you have created a project go to the project's dashboard and click the link to Enable an API. The API that you need to enable is Google Maps JavaScript API.

You then need to create a key for the API. At the time of writing the API key credentials page looks like this:

Setting the referrer

Pay careful attention to the Accept requests from these HTTP referes (web sites) section! Your API key is not a secret, anyone visiting your site can see it. If you do not lock the API key to your site they anyone can use your API key on their own sites.

Google impose daily limits on the number of map loads that you can make against the API key. If you exceed those limits then either your site will no longer be able to show the map or, worse still, if you have enabled billing then Google will charge you.

It goes without saying that you should not enable billing unless you know the implications of doing so, and only if you have locked your API key to your site.

It is very important that you lock the key to your site.

If your instance of VRS is running on a fixed IP address then you can enter the IP address into the referrers field. For example, if your server's IP address is 1.2.3.4 then you would enter:

http://1.2.3.4/*

Alternatively, if you are using a dynamic DNS service or you are serving the site from a domain then enter the site's address in the referrers field:

http://my-domain.com/*

If VRS is listening to a port that is not port 80 then remember to include that in the referrer field - so for example, if you are listening to port 8080 then the above examples would be http://1.2.3.4:8080/* and http://my-domain.com:8080/*.

Configuring VRS

You must be running at least version 2.4 of Virtual Radar Server. Earlier versions did not have support for entering Google Maps API keys.

In Tools | Options go to Web Site. Towards the bottom of the page you should see two fields:

Copy the API key from Google's site into the Google Maps API key field.

Do not tick the Use Google Maps API key with local requests unless Virtual Radar Server is unable to tell the difference between local and Internet requests on your network. Note that if you tick this option then you will only be able to see the map when you access the site from the Internet.