Forum

Thread tagged as: Question, Problem, Error

Google Maps API

Having difficulties enabling Google Maps API on a live site (Google's documentation is convoluted to say the least!).

Do I also have to add the API key to Perch here perch/config/config.php? I'm reading https://docs.grabaperch.com/templates/field-types/map/

And what is the second part 'abc123' ?

define('PERCH_GMAPS_API_KEY', 'abc123');
David Owen

David Owen 0 points

  • 4 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

that is where you put your API key.

Of course! Thanks. Map still not working though.

Should this key feed back into the script below? I see that CMSMap.key is blank CMSMap.key=''.

<script type="text/javascript">/* <![CDATA[ */ if(typeof CMSMap =='undefined'){var CMSMap={};CMSMap.maps=[];document.write('<scr'+'ipt type="text\/javascript" src="/cms/core/assets/js/public_maps.min.js"><'+'\/sc'+'ript>');}CMSMap.maps.push({'mapid':'cmsmap466-1','width':'300','height':'300','type':'map','zoom':'15','adr':'NN16 8LD','lat':'52.40855839642463','lng':'-0.733637809753418','clat':'52.40866832815391','clng':'-0.7336209888854994'});CMSMap.key='';/* ]]> */</script>

... I'm getting...

[Warning] Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys (util.js, line 211)
[Warning] Google Maps API warning: InvalidKey https://developers.google.com/maps/documentation/javascript/error-messages#invalid-key (util.js, line 211)
Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you saved your content since adding the API key to your config?

Boom! Working now. Thanks Drew/Rachel