-6

我写了这段代码,但有一个我无法弄清楚的问题:

我有一个包含 6 个浮点数的列表,但程序不会停止,case=6因此出现错误

@model IList<float>
@{ Layout = "~/Views/Shared/_Lay2.cshtml";
var culture = System.Globalization.CultureInfo.GetCultureInfo("en-US");}
<body  onload="initialize(@Model.Count.ToString(culture)">
  <table style="width: 100%; height: 70%">
    <tr>
      <td style="width: 100%">
        <div id="map_canvas" style="width: 100%; height: 500px;"></div>
      </td>
    </tr>
  </table>


  <script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
  <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
  <script type="text/javascript">
    function initialize(a) {

        var myLatLng = new google.maps.LatLng(@Model[0].ToString(culture), @Model[1].ToString(culture));
        var nextpoint = new google.maps.LatLng(@Model[2].ToString(culture), @Model[3].ToString(culture));
        var myOptions = {
            zoom: 8,
            center: myLatLng,
            mapTypeId: google.maps.MapTypeId.TERRAIN
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
        var flightPlanCoordinates = [
        new google.maps.LatLng(@Model[0].ToString(culture), @Model[1].ToString(culture)),
        new google.maps.LatLng(@Model[2].ToString(culture), @Model[3].ToString(culture)),

        ];
        var flightmarker1 = new google.maps.Marker({
            position: new google.maps.LatLng(@Model[0].ToString(culture), @Model[1].ToString(culture)),
            map: map,
            title: " denden"
        });
        var flightmarker2 = new google.maps.Marker({
            position: new google.maps.LatLng(@Model[2].ToString(culture), @Model[3].ToString(culture)),
            map: map,
            title: " denden"
        });

        var flightPath = new google.maps.Polyline({
            path: flightPlanCoordinates,
            strokeColor: "#FF0000",
            strokeOpacity: 1.0,
            strokeWeight: 2
        });
        flightPath.setMap(map);
        switch (a) {
        case 6:
            var flightPlanCoordinates = [
            new google.maps.LatLng(@Model[2].ToString(culture), @Model[3].ToString(culture)),
            new google.maps.LatLng(@Model[4].ToString(culture), @Model[5].ToString(culture)),

            ];
            var flightmarker1 = new google.maps.Marker({
                position: new google.maps.LatLng(@Model[2].ToString(culture), @Model[3].ToString(culture)),
                map: map,
                title: " denden"
            });
            var flightmarker2 = new google.maps.Marker({
                position: new google.maps.LatLng(@Model[4].ToString(culture), @Model[5].ToString(culture)),
                map: map,
                title: " denden"
            });

            var flightPath = new google.maps.Polyline({
                path: flightPlanCoordinates,
                strokeColor: "#FF0000",
                strokeOpacity: 1.0,
                strokeWeight: 2
            });
            flightPath.setMap(map);
            alert(a);
            break;
        case 8:
            var flightPlanCoordinates = [
            new google.maps.LatLng(@Model[2].ToString(culture), @Model[3].ToString(culture)),
            new google.maps.LatLng(@Model[4].ToString(culture), @Model[5].ToString(culture)),
            new google.maps.LatLng(@Model[6].ToString(culture), @Model[7].ToString(culture))];
            var flightmarker1 = new google.maps.Marker({
                position: new google.maps.LatLng(@Model[2].ToString(culture), @Model[3].ToString(culture)),
                map: map,
                title: " denden"
            });
            var flightmarker2 = new google.maps.Marker({
                position: new google.maps.LatLng(@Model[4].ToString(culture), @Model[5].ToString(culture)),
                map: map,
                title: " denden"
            });
            var flightmarker2 = new google.maps.Marker({
                position: new google.maps.LatLng(@Model[6].ToString(culture), @Model[7].ToString(culture)),
                map: map,
                title: " denden"
            });
            var flightPath = new google.maps.Polyline({
                path: flightPlanCoordinates,
                strokeColor: "#FF0000",
                strokeOpacity: 1.0,
                strokeWeight: 2
            });
            flightPath.setMap(map);
            break;
            alert(a);
        case 10:
            var flightPlanCoordinates = [
            new google.maps.LatLng(@Model[2].ToString(culture), @Model[3].ToString(culture)),
            new google.maps.LatLng(@Model[4].ToString(culture), @Model[5].ToString(culture)),
            new google.maps.LatLng(@Model[6].ToString(culture), @Model[7].ToString(culture)),
            new google.maps.LatLng(@Model[8].ToString(culture), @Model[9].ToString(culture))];
            var flightmarker1 = new google.maps.Marker({
                position: new google.maps.LatLng(@Model[2].ToString(culture), @Model[3].ToString(culture)),
                map: map,
                title: " denden"
            });
            var flightmarker2 = new google.maps.Marker({
                position: new google.maps.LatLng(@Model[4].ToString(culture), @Model[5].ToString(culture)),
                map: map,
                title: " denden"
            });
            var flightmarker2 = new google.maps.Marker({
                position: new google.maps.LatLng(@Model[6].ToString(culture), @Model[7].ToString(culture)),
                map: map,
                title: " denden"
            });
            var flightmarker2 = new google.maps.Marker({
                position: new google.maps.LatLng(@Model[8].ToString(culture), @Model[9].ToString(culture)),
                map: map,
                title: " denden"
            });
            var flightPath = new google.maps.Polyline({
                path: flightPlanCoordinates,
                strokeColor: "#FF0000",
                strokeOpacity: 1.0,
                strokeWeight: 2
            });
            flightPath.setMap(map);
            break;

        }

    }
  </script>

</body>
4

1 回答 1

0

不确定这是否是整个问题,您的身体标签上缺少一个右括号:

<body  onload="initialize(@Model.Count.ToString(culture))">  
// missing the second parens after culture.
于 2012-09-17T00:40:21.467 回答