我想在爲Google Maps API創建TileOverlay時訪問需要用戶/傳遞的不同主機上託管的一些自定義地圖塊。如何在ImageMapType的getTileUrl中添加授權標頭Javascript
所以這是我當前的代碼的Javascript:
var carte = new google.maps.ImageMapType({
getTileUrl: function (tileCoord, zoom) {
var url = "http://host.com/" + (zoom + 1) + "/" + (tileCoord.x + 1) + ":" + (tileCoord.y + 1) + "/tile.png";
return url;
},
tileSize: new google.maps.Size(256, 256),
minZoom: 8,
opacity: 0.6
});
map.overlayMapTypes.push(carte);
由於連接返回401 Anauthorized,我無法訪問的瓷磚。我怎麼能通過JavaScript/Jquery中的授權標題讓URL知道我有權訪問這些瓷磚?
我在尋找這樣一個解決方案,但在Javascript:Adding an Authorization header in getTileUrl for Maps Tile Android
您是否在尋找這個? https://developers.google.com/maps/documentation/javascript/get-api-key?hl=zh-CN –
我正在尋找這樣的解決方案:http://stackoverflow.com/questions/34739880/adding-an -authorization-header-in-gettileurl-for-maps-tile-android,但在Javascript中。 – Ulyanca