[Google Maps API] Map is not displayed and becomes blank [Rails]

I would like to write it as a reference for those who are making a personally developed application and have a memorandum and a similar error.

error contents

I'm making a personally developed app with Rails. A function that acquires latitude and longitude (latitude, longitude) from an address when posting store information and displays it on a map.

As shown in the picture below, the map (Google Maps) is not displayed at the position where it should be displayed, and it is blank. It was able to be displayed normally until a few days ago.

And the map is displayed for the store information posted a few days ago. In other words, if you post a new post, the latitude and longitude cannot be obtained correctly from the address information, and the map cannot be displayed. スクリーンショット 2020-10-30 9.50.37.png

TRY for error

When I checked Google Cloud Platform, I was able to confirm that the Geocoding API was 100% error. スクリーンショット 2020-10-30 10.07.52.png

The cause is unknown even if it is investigated using a verification tool by Chrome. From the above Geocoding error, it can be inferred that the latitude and longitude cannot be obtained correctly from the address information (address).

When I investigate the error, I get API key setting mistakes and JavaScript description mistakes, but I could see it normally until a few days ago, and as mentioned above, all the past posts have maps. It is displayed correctly. In other words, it should not be a JavaScript typo.

Everything should have been set correctly to display the map, and it was displayed normally until a few days ago, so I thought there was something else, but no matter what I did for a few hours, it didn't fix. I haven't fixed anything on GitHub compared to the past of potentially relevant files.

Solution

I searched overseas sites such as StackOverFlow, but I couldn't find a decisive hit. When I was at a loss, ** I am using Docker for environment construction, so I decided to drop Docker once and build it again. ** **

local


$ docker-compose down
$ docker-compose build
$ docker-compose up -d
$ docker-compose run web rails db:create
$ docker-compose run web rails db:migrate

When I accessed the local host again in the test environment, I confirmed that the map was displayed safely. Even if I changed the address, I confirmed that the map was displayed by acquiring the latitude and longitude from the changed address information. Since we confirmed normal operation, we reflected it in the production environment (git push because CircleCI has already been installed). Confirm normal operation even in production and solve it!

Learn

I learned that restarting Docker can sometimes be a useful hit. Even when deploying AWS, the error was resolved at once by restarting EC2, so I was able to reconfirm that it is better to restart the environment once when doing everything. If you are using Docker with Rails and have introduced Google Maps API, and if it is displayed blank in the same way, please restart Docker once.

Recommended Posts

[Google Maps API] Map is not displayed and becomes blank [Rails]
Display Google Maps API with Rails and pin display
[Rails] google maps api How to post and display including map information
Beginners of Google Maps API and Twitter API made "tweet map"
Introducing Google Map API with rails
Note that the Google Maps Android API GoogleMap.getProjection is not a singleton
[Rails] Google Maps API Description when latitude and longitude cannot be saved
[Rails] Displaying Google Maps using Google Maps API and searching routes between multiple points
[Rails 6 / Google Map API] Post an address and set multiple markers on the map
Email Services-Postfix and Devecot
Beginners of Google Maps API and Twitter API made "tweet map"
Book registration easily with Google Books API and Rails
[Map display] Display a map from the address registered by the user using the Google Maps JavaScript API and Geocoding API!
[Ruby on Rails] Display and pinning of GoolgeMAP using Google API
[Rails] How to display Google Map
Google API access token and refresh token
[Rails] How to calculate latitude and longitude with high accuracy using Geocoding API and display it on Google Map