2013-07-04 50 views
1

我想將多個標記繪製到谷歌地圖上。使用C#向JavaScript註冊數組#

我有沒有他們的經度和langitude在數據庫中的多個地址..

我caluculate經度和使用谷歌API的每個地址的langitude ..

現在我想註冊一個JavaScript變量與收集地址,變形,lang度等。

因此,我在JavaScript中獲取該變量並在Google地圖中映射多個標記。

。需要註冊一個JavaScript變量像這樣在C#..

var locations = [ 
    ['Bondi Beach', -33.890542, 151.274856], 
    ['Coogee Beach', -33.923036, 151.259052], 
    ['Cronulla Beach', -34.028249, 151.157507], 
    ['Manly Beach', -33.80010128657071, 151.28747820854187], 
    ['Maroubra Beach', -33.950198, 151.259302] 
]; 

回答

0

您可以爲地理編碼和消息的一些東西像下面創建字符串數組。可用工作副本http://deepumi.wordpress.com/tag/google-map-3-in-asp-net-c/

protected void Page_Load(object sender, EventArgs e) 
{ 
    var geocodes = new List<String> 
    { 
     " '40.756012, -73.972614' ", 
     " '40.456012, -73.796087' ", 
     " '40.456012, -73.456807' " 
    }; 

    var geocodevalues = string.Join(",", geocodes.ToArray()); 

    var titles = new List<String> 
    { 
     " 'Google Map 3 Awesome !!!' ", 
     " 'Made it very simple' ", 
     " 'Google Rocks' " 
    }; 

    var message = string.Join(",", titles.ToArray()); 

    ClientScript.RegisterArrayDeclaration("locationList", geocodevalues); 

    ClientScript.RegisterArrayDeclaration("message", message); 
}