!!更新 !!谷歌地圖實施問題&API前綴錯誤
我有一點麻煩讓我的谷歌地圖顯示正確,我在控制檯日誌中得到這個錯誤。我已經嘗試調整示例中列出的前綴here。不過,我覺得我仍然沒有正確理解這一點。任何人都可以用我的語言來解釋這個嗎?
1 - Prefixed Fullscreen API is deprecated. Please use unprefixed API for fullscreen. For more help https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
這是我相信errornous代碼;
// Google Map Element
var mapElement = document.getElementById('map');
// I added thes lines to try and solve the prefix error.
if (mapElement.requestFullscreen) {
mapElement.requestFullscreen();
}
編輯:
好了,所以有點麻煩已經變成了一對夫婦的試驗和錯誤的天。我嘗試了許多不同的方法來解決這個問題,但我不認爲我很滿意,不會犯錯。
只是爲了更新我的錯誤日誌;
1 - TypeError: google is undefined p-apollo:32:5
2 - Prefixed Fullscreen API is deprecated. Please use unprefixed API for fullscreen. For more help https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API controls.js:23:54
3 - "Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error" js:32:350
4 - "Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys" util.js:222:12
5 - "Google Maps API warning: SensorNotRequired https://developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required" util.js:222:12
注: 我已經生成並inclu從谷歌代理API密鑰,但因爲我在本地運行;我已經評論了這一點,並在其中添加了以下內容。我嘗試添加另一個答案中提到的API的發佈版本。
<!-- Google Maps API -->
<script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3"></script>
全碼組塊
只是爲了掩飾我所添加的代碼塊我在的地方我的谷歌地圖的基礎。如果有人可以請掃描一下,並確保我沒有發生noob錯誤,我將不勝感激,有時第二組眼睛是解決方案。
<!-- Google Maps Script -->
<script type="text/javascript">
// create google map on doc load
google.maps.event.addDomListener(window, 'load', init);
function init() {
var mapOptions = {
zoom: 11,
// The latitude and longitude to center the map (always required)
center: new google.maps.LatLng(40.6700, -73.9400),
styles: [{
"featureType": "landscape",
"stylers": [{
"hue": "#FFBB00"
}, {
"saturation": 43.400000000000006
}, {
"lightness": 37.599999999999994
}, {
"gamma": 1
}]
}, {
"featureType": "road.highway",
"stylers": [{
"hue": "#FFC200"
}, {
"saturation": -61.8
}, {
"lightness": 45.599999999999994
}, {
"gamma": 1
}]
}, {
"featureType": "road.arterial",
"stylers": [{
"hue": "#FF0300"
}, {
"saturation": -100
}, {
"lightness": 51.19999999999999
}, {
"gamma": 1
}]
}, {
"featureType": "road.local",
"stylers": [{
"hue": "#FF0300"
}, {
"saturation": -100
}, {
"lightness": 52
}, {
"gamma": 1
}]
}, {
"featureType": "water",
"stylers": [{
"hue": "#0078FF"
}, {
"saturation": -13.200000000000003
}, {
"lightness": 2.4000000000000057
}, {
"gamma": 1
}]
}, {
"featureType": "poi",
"stylers": [{
"hue": "#00FF6A"
}, {
"saturation": -1.0989010989011234
}, {
"lightness": 11.200000000000017
}, {
"gamma": 1
}]
}]
};
// Google Map Element
var mapElement = document.getElementById('map');
if (mapElement.requestFullscreen) {
mapElement.requestFullscreen();
}
var map = new google.maps.Map(mapElement, mapOptions);
// Map Marker
var marker = new google.maps.Marker({
position: new google.maps.LatLng(40.6700, -73.9400),
map: map,
title: 'title'
});
}
</script>
測試了: - 火狐47.0 - 鉻51.0.2704.103
應該工作正常,你確定你沒有使用不同版本的文件或類似的東西? – gcampbell
不是我所知道的,在刷新時足夠強大,它在一瞬間工作,然後拋出一個錯誤。我正在通過xampp進行測試,它有所幫助嗎? – Beaniie
您使用哪種瀏覽器? – gcampbell