这是我要在 jquery 函数中导入的hotspot.json 文件。我遇到的问题是热点值上的引号。没有它们,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 文件中的问题?有人可以帮我解决这个问题吗?