MissingKeyMapError Fix and Other Google Map Revisitations

It can be difficult to keep up with all of the provider API changes that affect your app. If you're using the Google Maps API, for instance, you might want to display a map or two in your app to confirm you're not seeing something like this.

Recently Google required a key when using the Maps API, which is cool. Here's a good reference piece on approaching the fix. I was actually using a key from the beginning, but it wasn't a Maps API-specific key, or was from another app, or something…

Here's the updated Maps API Url in NixMash Spring with the aid of Spring MVC and Thymeleaf, i.e., the ${appSettings.googleMapKey} at the end of the url.

ApplicationSettings is a Spring External Properties Class which we talked about before. We're passing those properties to the client from our @ControllerAdvice Controller.

@ModelAttribute("appSettings")
public ApplicationSettings getApplicationSettings() {
return applicationSettings;
}

If you're forking NixMash Spring or using it for anything, you might want to add a googleMapKey property to ApplicationSettings and your external properties file.

The Second Map API Glitch

We have what I think is a very cool multi-location map demo we generate on the fly using Geo-location data from our Solr Products index. On a good day it looks like this.

Recently it loaded with a single location tag in the center of a tan blob of nothingness. Having other priorities we temporarily removed the link to the map on the demo site, but you'll be thrilled to know it's back online and should hopefully look like the map above.

That particular API Glitch was caused by the fact that the InfoBox Utility library was removed from Google Code, which is where we were calling it from. We rectified our earlier mistake of not downloading infobox.js to run locally. Our multi-location map scripts with infobox.js now look like this.

Alternative title for this post: Keeping up with Provider API Changes For Fun and Profit!

Source Code Notes for this Post

All source code discussed in this post can be found in my NixMash Spring GitHub repo and viewed online here.

Posted July 01, 2016 02:04 PM EDT

More Like This Post