2014-12-10 156 views
0

我正在使用名爲Mapael的jQuery插件,並試圖做一些相當簡單的事情。另一個對象內的JavaScript對象

函數底部的「圖」對象將添加繪圖點到地圖。情節點也是對象。

我的目標是根據外部JSON文件動態生成這些繪圖點。我已經爲練習做了一些情節點,並將它們存儲在鄉村物體中。

有什麼辦法可以將「country」對象用作「plot」對象的值嗎?

var country = { 
    "XM": { 
     value: 100, 
     latitude: 22.99131, 
     longitude: 54.77059 
    }, 
    "VE": { 
     value: 200, 
     latitude: 64.42689, 
     longitude: 145.23237 
    }, 
    "SE": { 
     value: 300, 
     latitude: 8.96106, 
     longitude: -15.09699 
    }, 
    "XF": { 
     value: 300, 
     latitude: 50.93900, 
     longitude: 55.38883 
    } 
} 

$('.world').mapael({ 
    // ... other mapael objects to initialize map 

    plots: { 
     // country object 
    } 
}); 

回答

3

是的。省略大括號,只是參考變量:

$('.world').mapael({ 
    // ... 
    plots: country 
}); 
+0

謝謝你的幫助! – user3272622 2014-12-10 23:47:03

相關問題