Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/456.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用C将数组注册到JavaScript#_Javascript - Fatal编程技术网

使用C将数组注册到JavaScript#

使用C将数组注册到JavaScript#,javascript,Javascript,我想在谷歌地图上绘制多个标记 我在数据库中有多个地址,没有经度和语言 我使用谷歌api计算每个地址的经度和语言 现在我想注册一个JavaScript变量,其中包含address、longitute、languites等的集合 因此,我在JavaScript中获取该变量,并在GoogleMap中映射多个标记 需要在C#中注册这样的JavaScript变量 您可以为地理编码和消息创建字符串数组,如下所示。可提供一份工作副本 受保护的无效页面加载(对象发送方,事件参数e) { var geocodes

我想在谷歌地图上绘制多个标记

我在数据库中有多个地址,没有经度和语言

我使用谷歌api计算每个地址的经度和语言

现在我想注册一个JavaScript变量,其中包含address、longitute、languites等的集合

因此,我在JavaScript中获取该变量,并在GoogleMap中映射多个标记

需要在C#中注册这样的JavaScript变量


您可以为地理编码和消息创建字符串数组,如下所示。可提供一份工作副本

受保护的无效页面加载(对象发送方,事件参数e)
{
var geocodes=新列表
{
" '40.756012, -73.972614' ",
" '40.456012, -73.796087' ",
" '40.456012, -73.456807' "
};
var geocodevalues=string.Join(“,”,geocodes.ToArray());
var titles=新列表
{
“'谷歌地图3真棒!!!'”,
“‘做得很简单’”,
“‘谷歌摇滚’”
};
var message=string.Join(“,”,titles.ToArray());
ClientScript.RegisterArrayDeclaration(“locationList”,geocodevalues);
RegisterArrayDeclaration(“message”,message);
}
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]
];
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);
 }