0

ポリラインを描画しようとしていますが、オーバーロードメソッドにエラーがあり、正しく実行しているときにエラーが発生する理由を取得できません...私のコード、

   private void BuildScript(DataTable tbl)
        {
            String Locations = "";
            String locations = "";
            foreach (DataRow r in tbl.Rows)
            {
                // bypass empty rows        
                if (r["Latitude"].ToString().Trim().Length == 0)
                    continue;

                string Latitude = r["Latitude"].ToString();
                string Longitude = r["Longitude"].ToString();
                double latitude = Convert.ToDouble(r["Latitude"]);
                double longitude =Convert.ToDouble(r["Longitude"]);
                var points = new List<GLatLng> {new GLatLng(latitude,longitude)};
                var polyline = new GPolyline(points); 
                // create a line of JavaScript for marker on map for this record    
                Locations += Environment.NewLine + " map.addOverlay(new GMarker(new GLatLng(" + Latitude + "," + Longitude + ")));";
                locations += Environment.NewLine + " map.addOverlay(new GPolyline(new GLatLng(" + Latitude + "," + Longitude + ")));";
            }

            // construct the final script
            js.Text = @"<script type='text/javascript'>
                            function initialize() {
                              if (GBrowserIsCompatible()) {
                                var map = new GMap2(document.getElementById('map_canvas'));
                                map.setCenter(new GLatLng(45.05,7.6667), 2); 
                                " + Locations + @"
                                map.setUIToDefault();
                              }
                            }
                            </script> ";
   js.Text = @"<script type='text/javascript'>
                            function initialize() {
                              if (GBrowserIsCompatible()) {
                                var map = new GMap2(document.getElementById('map_canvas'));
                                map.setCenter(new GLatLng(45.05,7.6667), 2); 
                                " + locations + @"
                                map.setUIToDefault();
                              }
                            }
                            </script> ";
}

スクリプトのエラーが発生しましたポリラインが存在しません

お返事をお待ちしております...

4

1 に答える 1

1

GPolyline コンストラクターには型の変数が必要ですが、List<GLatLng>それはあなたが渡しているものではありません。

GLatLng 値をリストとして作成する必要があります。

var points = new List<GLatLng> { new GLatLng(59.6919, 17.8582),new GLatLng(59.3030, 18.0395),new GLatLng(58.9789, 17.5341) };
var polyline = new GPolyline(points,"#ff0000",1); 
于 2011-08-12T05:52:11.107 に答える