简体   繁体   中英

Embed a map from Google Maps Engine

A friend of mine has a Google Maps Engine account where he loads up map data which he want's to share with users. These maps are private (ie you need to log in to view them). I've made a system using PHP where people can login to my friends website and I want them to be able to view these maps embedded in his website.

In the Google Maps Engine (GME) interface each map has an ' API ID ' and ' Layer names/keys '.

I also have a an API Project with an API Key, client ID, secret etc. Using my API Project I've been able to get an Access token and a Refresh token for my email address which is in the "viewable by" section of the GME interface.

My goal is that I can log onto my friend's website then, using server side PHP, use the refresh token which is now stored in a database, get an access token and echo the content part of his page with the map inside it.

This is what I want to do https://developers.google.com/maps/documentation/javascript/examples/mapsenginelayer-noauth-layerkey

But with Authentication.

I figured it out, in case anyone else has the same question you just need to add

accessToken: 'the_access_token' ,

In the list of Maps Engine Layer options. I fount the answer here: https://developers.google.com/maps/documentation/javascript/3.exp/reference#MapsEngineLayerOptions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM