@{
    ViewBag.Title = "查看地图";
    Layout = "~/Views/Shared/_LayoutTable.cshtml";
}
@section head{
<style type="text/css">
    body, html, #allmap {
        width: 100%;
        height: 100%;
        overflow: hidden;
        margin: 0;
    }

    #l-map {
        height: 100%;
        width: 78%;
        float: left;
        border-right: 2px solid #bcbcbc;
    }

    #r-result {
        height: 100%;
        width: 20%;
        float: left;
    }
</style>
    }
<body>
    <div id="allmap">
    </div>
</body>
<script type="text/javascript">
    var map = new BMap.Map("allmap");
    var arralls = "@ViewBag.str";
    var arrgps = arralls.split("#");
    for (var j = 0; j < arrgps.length; j++) {
        var arrgpsname = arrgps[j].split("★");
        for (var k = 0; k < arrgpsname.length; k++) {
            var arrall = arrgpsname[0].split("|");
            var arr0 = arrall[0].split(",");
            var point = new BMap.Point(arr0[0], arr0[1]);
            map.centerAndZoom(point, 10);
            var PointArr = [];
            for (var i = 0; i < arrall.length; i++) {
                var arrsin = arrall[i].split(",");
                PointArr.push(new BMap.Point(arrsin[0], arrsin[1]));

                //转折点画点
                var point = new BMap.Point(arrsin[0], arrsin[1]);
                map.centerAndZoom(point, 15);
                // 编写自定义函数,创建标注
                function addMarker(point) {
                    var marker = new BMap.Marker(point);
                    map.addOverlay(marker);
                }

                var polyline = new BMap.Polyline(
    PointArr, { strokeColor: "blue", strokeWeight: 4, strokeOpacity: 0.5 });
                map.addOverlay(polyline);
                map.addControl(new BMap.NavigationControl());
                map.addControl(new BMap.ScaleControl());
                map.addControl(new BMap.OverviewMapControl());
                map.addControl(new BMap.MapTypeControl());
                map.enableScrollWheelZoom();
                var marker1 = new BMap.Marker(point);
                map.addOverlay(marker1);
                //           时间
                var label = new BMap.Label(arrgpsname[1] + arrsin[2], { offset: new BMap.Size(20, -10) });
                label.setStyle({
                    position: "relative"
                })
                marker1.setLabel(label);
                var infoWindow1 = new BMap.InfoWindow(arrgpsname[1] + arrsin[2]);

            }
        }
    }
</script>

