Google Maps API V3 - 日语字符串比较和标记图像

时间:2014-07-17 09:25:14

标签: javascript google-maps google-maps-api-3

我正在使用Google Maps API V3 for JavaScript构建一个简单的地图应用程序。我想根据IF条件为每个位置显示一个标记图像。这是一些代码:

var myIcon, greenPinIcon, bluePinIcon;
greenPinIcon = new google.maps.MarkerImage("images/pin_green.png", null, null, null, new google.maps.Size(50,50));
bluePinIcon = new google.maps.MarkerImage("images/pin_blue.png", null, null, null, new google.maps.Size(50,50));

for(i=0; i<locations.length; i++)
{
  if (locations[i][5] == "保守新政の会")
     {
           myIcon = greenPinIcon;
     }
  else
     {
           myIcon = bluePinIcon;
     }

        marker = new MarkerWithLabel(
            {
                position: position,
                map: map,
                draggable: false,
                raiseOnDrag: false,
                title: locations[i][2],
                labelContent: locations[i][2],
                labelAnchor: new google.maps.Point(50, 0),
                labelClass: "labels", // the CSS class for the label
                labelStyle: {opacity: 0.75},
                icon: myIcon
            }
        );

}

&#34;位置&#34;是一个包含值的多维数组:纬度,经度,名称,电话,地址,组。这里有几行作为样本。

35.866446,139.803246,伊藤治,985-4826,越谷市蒲生三丁目7番7号,自由民主党/市民クラブ
35.877096,139.770734,野口佳司,964-9527,越谷市七左町七丁目175番地,自由民主党/市民クラブ
35.869426,139.780875,樫村紀元,987-1985,越谷市七左町一丁目332番地9,保守新政の会

我无法看到所需的结果,所有标记都显示在&#34; bluePinIcon&#34;作为标记图标。我不确定它是日语字符串还是导致问题的其他因素。我还包括<meta charset="utf-8" />以支持unicode字符。

我是JavaScript和Google Maps API的新手。任何帮助将不胜感激。

感谢。

0 个答案:

没有答案
相关问题