@using MES.Production.Service;
@using Central.Control.Domain;
@using Ant.Service.Common;
@using Ant.Service.Common.Enums;
@using MES.Production.Entity;

@model EntSYS_DISTRIBUTORS
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>经销商围栏信息</title>
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css" />
    <script src="http://webapi.amap.com/maps?v=1.3&key=fa36ec6323075f37020083ceffe8eb24"></script>
    <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
    <script src="http://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>

</head>
<body>
    <div id="container"></div>
    <script>
        var map = new AMap.Map('container', {
            resizeEnable: true,
            center: [@Model.Theodolite],
            zoom: 13
        });


        var circle = new AMap.Circle({
            center: new AMap.LngLat("@Model.Theodolite.Split(',')[0]", "@Model.Theodolite.Split(',')[1]"),// 圆心位置
            radius: @(Model.FenceRadius/2), //半径
            strokeColor: "#ff0000", //线颜色
            strokeOpacity: 0.5, //线透明度
            strokeWeight: 3,    //线宽
            fillColor: "#ff6699", //填充色
            fillOpacity: 0.1//填充透明度
        });

        //声明一个list
        var list = {
            "size": 4,
            "data": [
                { "x": 116.397428, "y": 39.921883 },
                { "x": 116.397428, "y": 39.920213 },
                { "x": 116.403322, "y": 39.922282 },
                { "x": 116.403322, "y": 39.920249 }
            ]
        }

        for (var j = 0, map; j < list.size; j++) {
            var myObj = list.data[j];
            var myLngLat = new AMap.LngLat(myObj.x, myObj.y);
            console.log(circle.contains(myLngLat));
            if (circle.contains(myLngLat)) {//如果点在圆内则输出
                var marker = new AMap.Marker({
                    position: myLngLat,
                    map: map
                });
            }

        }

        circle.setMap(map);//显示圆圈
        map.setFitView();//根据地图上添加的覆盖物分布情况,自动缩放地图到合适的视野级别


         AMapUI.loadUI(['overlay/SimpleInfoWindow'], function (SimpleInfoWindow) {

            var marker = new AMap.Marker({
                map: map,
                zIndex: 99999,
                offset: new AMap.Pixel(-5, -20),//相对于基点的位置
                //icon: new AMap.Icon({  //复杂图标
                //    size: new AMap.Size(14, 20),//图标大小
                //    image: "http://47.96.20.14:8086/Content/map/map-marker-icon.png", //大图地址

                //})
                //draggable: true,  //是否可拖动
                iconStyle: {
                    src: 'http://47.96.20.14:8086/Content/map/map-marker-icon.png',
                    style: {
                        width: '14px',
                        height: '20px'
                    }
                },

            });

            var infoWindow = new SimpleInfoWindow({
                infoTitle: '<strong>经销商地址:</strong>',
                infoBody: '<p class="my-desc"><strong>@Model.Address<br/></strong></p>',

                //基点指向marker的头部位置
                offset: new AMap.Pixel(0, -31)
            });

            function openInfoWin() {
                infoWindow.open(map, marker.getPosition());
            }

            //marker 点击时打开
            AMap.event.addListener(marker, 'click', function () {
                openInfoWin();
            });


        });

    </script>
</body>
</html>
@*https:blog.csdn.net/dKnightL/article/details/74787775*@