keskiviikko 2. marraskuuta 2016

Google Maps API error - MissingKeyMapError

http://stackoverflow.com/questions/37991340/error-google-maps-api-error-missingkeymaperror

Tämä ongelma voi tulla eteen, jos html-sivulle on upotettu Google:n kartta. Javascipt antaa otsikon mukaisen virheen.

Syy on tässä:


As per Google recent announcement, usage of the Google Maps APIs now requires a key. If you are using the Google Maps API on localhost or your domain was not active prior to June 22nd, 2016, it will require a key going forward. Please see the Google Maps APIs documentation to get a key and add it to your application.


Korjaus tässä:

Vika korjaantuu helposti hankkimalla ilmaisen Key:n Google Maps API:a varten ja kertomalla siitä koodissa.

Eli muuta tämä:
<script src="https://maps.googleapis.com/maps/api/js"></script>

Tällaiseksi:
<script src="https://maps.googleapis.com/maps/api/js?libraries=places&key=your_api_key_here"></script>