Rails 4 - Google Maps with gmaps4rails gem

Mel

I am trying to figure out how to use gmaps4rails gem in my Rails 4 app.

I have a view partial in which I have inserted the 3 script tags shown in the documentation, replacing the API key with my own (which is stored in my environment secrets file).

<script src="//maps.google.com/maps/api/js?v=3.23&key=ENV['GOOGLE_MAPS_API_KEY']"></script>

I think I may have done this incorrectly, because I can't currently load maps. The error message I see when I inspect the console from Chrome is:

util.js:220 Google Maps API warning: InvalidKey https://developers.google.com/maps/documentation/javascript/error-messages#invalid-key

Can anyone see if I have made an error in the way I have inserted my API key to this script?

Vic

You are inserting a ruby snippet into a .html.erb file, so u need the <%=%> to interpolate the ruby string

<script src="//maps.google.com/maps/api/js?v=3.23&key=<%= ENV['GOOGLE_MAPS_API_KEY'] %>"></script>

Check inspect element of ur html page to see that the url is interpolated correctly.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Rails 4 - Google Maps with gmaps4rails gem

From Dev

scope of markers variable for google maps (gmaps4rails gem)

From Dev

Disable zoomOnclick when initializing Google maps with "Gmaps4rails"

From Dev

broken google map with gmaps4rails

From Dev

gmaps4rails gem: to_gmaps4rails method undefined

From Dev

gmaps4rails v2 - multiple maps

From Dev

How to display two gmaps4rails on same page one regular map and one in street view (Google Maps and Rails)

From Dev

Gmaps4rails - Rails 4

From Dev

gmaps4rails infowindows (ruby/rails)

From Dev

Gmaps.build('Google') TypeError: undefined is not a function Gmaps4Rails

From Dev

First load time app loads using Gmaps4rails gem map won't load

From Dev

How to Center Marker in Gmaps4rails

From Dev

GMaps4Rails MarkerCluster anchorText

From Dev

Ajax reloading in Gmaps4rails

From Dev

Gmaps4Rails - custom infowindow not working

From Dev

Issue with rspec and gmaps4rails

From Dev

Ajax reloading in Gmaps4rails

From Dev

gmaps4rails in show view

From Dev

Gmaps4Rails - custom infowindow not working

From Dev

Bootstrap Nav Tabs and gmaps4rails

From Dev

How to make searchbox for gmaps4rails

From Dev

How to rotate marker in rails using gmaps4rails?

From Dev

Gmaps4rails turbolink disable not working - Rails 5

From Dev

Rails 4: Google Maps not displaying

From Dev

Gmaps4Rails - Custom marker picture not clickable / not opening infowindow

From Dev

Accessing json attributes from marker - gmaps4rails

From Dev

gmaps4rails v2 - map type

From Dev

InfoBoxBuilder gmaps4rails v2 not working

From Dev

Gmaps4rails V2 - change default zoom