這是我想要在jquery函數中導入的hotspot.json文件。我遇到的問題是熱點價值上的引號。沒有他們的JSON文件無效,但現在它不起作用。在不帶引號的jquery函數中導入json文件
[
{
"pitch": 14.1,
"yaw": 1.5,
"cssClass": "custom-hotspot",
"createTooltipFunc": hotspot,
"createTooltipArgs": "Baltimore Museum of Art"
},
{
"pitch": -9.4,
"yaw": 222.6,
"cssClass": "custom-hotspot",
"createTooltipFunc": hotspot,
"createTooltipArgs": "Art Museum Drive"
},
{
"pitch": -0.9,
"yaw": 144.4,
"cssClass": "custom-hotspot",
"createTooltipFunc": hotspot,
"createTooltipArgs": "North Charles Street"
}
]
這就是我在這個時候導入json文件的方法。
var hotspots = (function() {
$.ajax({
'async': false,
'global': false,
'url': "/hotspot.json",
'dataType': "json",
'success': function (data) {
hotspots = data;
}
});
return hotspots;
})();
在這一點上,我不知道從哪裏開始。我是否需要在我的json文件中更改某些內容或修復js文件中的問題?有人可以幫我解決這個問題嗎?
你能解釋爲什麼你想讓這些值沒有引號嗎? – yarwest
你好yarwest,否則它不工作。通常我必須將熱點配置放入函數中。例如:[link](https://pannellum.org/documentation/examples/custom-hot-spots/)但需要它是一個外部文件。 – Damenace
從我能看到你發送的鏈接中,你想把熱點函數放入JSON數據中? – yarwest