0

I am trying to run the following example on plotGoogleMaps:

library(plotGoogleMaps)
data(meuse)
coordinates(meuse)<-~x+y # convert to SPDF
proj4string(meuse) <- CRS('+init=epsg:28992')
# adding Coordinate Referent Sys.
# Create web map of Point data
m<-plotGoogleMaps(meuse,filename='myMap1.html')

I started loading this on Google Chrome but it gives the following error message on browser:

Error message on browser

989
  • 12,579
  • 5
  • 31
  • 53
Shana
  • 11
  • 2

1 Answers1

0

I just tried this using R 3.3.0 on a Macbook Air running Mavericks and I was able to open the map successfully in Google Chrome.

Given the date of your post, I believe you may have run into a change that Google made and then reversed (temporarily). The plotGoogleMaps package creates an htm file that can be opened in a browser. The htm file makes a call to the Google Maps JavaScript API.

On June 22nd, Google made a change that caused most maps opened via a file (vs. from a website) to fail. See the post: http://googlegeodevelopers.blogspot.com/2016/06/building-for-scale-updates-to-google.html.

Essentially, Google wants to require the use of an "api key" or a "client ID" for all Google maps applications going forward. Because of the pushback from the user community, Google has temporarily grandfathered the ability to open a Google map using the "file://" referrer without a key. But this is not going to be the case long term. To get an API key, look here: https://developers.google.com/maps/documentation/javascript/get-api-key.

To use an api key with plotGoogleMaps, use the "api" argument as follows:

api="https://maps.googleapis.com/maps/api/js?libraries=visualization&key=YOUR_KEY_HERE"

A few last things to note:

  1. plotGoogleMaps creates htm files that can either be opened directly as a file or served up from a website. If you send the map as a file to others (file:// referer), you have to set your Google Maps api key to allow ALL file:// referers since you won't know where the file exists on the recipients computer. Technically, this opens you up to "quota theft" since you've opened you api key to all file:// referers. Google is working on a solution to this problem.

  2. In plotGoogleMaps, if you do not specify the filename argument, the map will be opened using the default browser using a connection that starts with http://localhost:. Note: Google does not recognize this referer and will display a "Oops! Something went wrong" message.

    Since http://localhost: is by definition equivalent to http://127.0.0.1:, if you change the URL the map will load correctly. I've pointed this out to Google but they have informed me that the list of grandfathered referers has already been decided and http://localhost didn't make it although http://127.0.0.1 did. Go figure.

Community
  • 1
  • 1
Mac471
  • 423
  • 5
  • 16