2013-06-19 98 views
0

我正在使用谷歌地圖api拉入地圖到phonegap應用程序。地圖工作正常,但我試圖設置自定義標記,並遵循如下:https://developers.google.com/maps/documentation/javascript/overlays#Icons谷歌地圖API設置標記保留字

您在哪裏設置圖像代碼使用「錨點」設置。這是JavaScript中的保留字,如果它留在代碼中,則JavaScript將失敗。

我該如何解決這個問題?

var image = { 
url: 'images/beachflag.png', 
// This marker is 20 pixels wide by 32 pixels tall. 
size: new google.maps.Size(20, 32), 
// The origin for this image is 0,0. 
origin: new google.maps.Point(0,0), 
// The anchor for this image is the base of the flagpole at 0,32. 
anchor: new google.maps.Point(0, 32) 

};

回答

1

從什麼時候錨定保留字?其次,如果你正在使用的對象保留字作爲密鑰,只需把它們放在引號像

{ 
'anchor': new google.maps.Point(0,32) 
} 
+0

感謝您的回答,但我不認爲你需要降級我的答案。就像在我的ide裏放置主播節目一樣。我想弄清楚,如果它jQuery或jQuery的移動。並將其留在代碼中停止運行。 –

+0

不需要IDE - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Reserved_Words – Adam