$(function () {
        var worldMapContainer1 = document.getElementById('distribution_map');
        var mapOptions = {
            scene: {
                center: {lat: 35.274526, lng: 117.981585, alt: 20000, heading: 0, pitch: -90},
                showSun: true,
                showMoon: true,
                showSkyBox: true,
                showSkyAtmosphere: false, //关闭球周边的白色轮廓 map.scene.skyAtmosphere = false
                fog: true,
                fxaa: true,
				infoBox: false,
                globe: {
                    showGroundAtmosphere: false, //关闭大气（球表面白蒙蒙的效果）
                    depthTestAgainstTerrain: false,
                    baseColor: "#546a53",
                },
                cameraController: {
                    zoomFactor: 3.0,
                    minimumZoomDistance: 1,
                    maximumZoomDistance: 50000000,
                    enableRotate: true,
                    enableZoom: true,
                },
            },
            control: {
                // baseLayerPicker: true, //basemaps底图切换按钮
                // homeButton: true, //视角复位按钮
                // sceneModePicker: true, //二三维切换按钮
                // navigationHelpButton: true, //帮助按钮
                // fullscreenButton: true, //全屏按钮
                // defaultContextMenu: true, //右键菜单
            },
            basemaps: [
                {
                    name: "天地图影像",
                    icon: "img/basemaps/tdt_img.png",
                    type: "tdt",
                    layer: "img_d",
                    key: ["9ae78c51a0a28f06444d541148496e36"],
                    show: true,
				},
				{ 
					name: "天地图注记", 
					type: "tdt", 
					layer: "vec_z", 
					key: ["9ae78c51a0a28f06444d541148496e36"], 
					show: true,
				},
            ],
            layers:[
                {
                    pid:0,
                    name: "镇界",
                    type: "wms",
                    url: "http://175.27.168.120:8080/geoserver/feixian/wms",
                    layers: "feixian:zhenjie",
                    crs: "EPSG:4326",
                    parameters: { transparent: "true", format: "image/png" },
                    show: true,
                    flyTo: true,
                },
                // {
                //     name: "县界",
                //     type: "wms",
                //     url: "http://175.27.168.120:8080/geoserver/feixian/wms",
                //     layers: "feixian:xianjie",
                //     crs: "EPSG:4326",
                //     parameters: { "transparent": "true", "format": "image/png" },
                //     showClickFeature: false,
                //     // center: { "lat": 35.014426, "lng": 118.167223, "alt": 3710, "heading": 359.2, "pitch": -90, "roll": 360 },
                //     show: false,
                //     flyTo: true
                // },
                // {
                //     name: "历史图斑",
                //     type: "wms",
                //     url: "http://175.27.168.120:8080/geoserver/feixian/wms",
                //     layers: "tanyizhen:anjianjilu",
                //     crs: "EPSG:4326",
                //     parameters: { "transparent": "true", "format": "image/png" },
                //     // center: { "lat": 35.014426, "lng": 118.167223, "alt": 3710, "heading": 359.2, "pitch": -90, "roll": 360 },
                //     show: true,
                //     // flyTo: true
                // },
            ],
        }
        var map = new mars3d.Map('distribution_map', mapOptions)
        // arcGisLayer = new mars3d.layer.ArcGisLayer({
        //     name: "合肥建筑物",
        //     url: "//server.mars3d.cn/arcgis/rest/services/mars/guihua/MapServer",
        //     highlight: {
        //         clampToGround: true,
        //         fill: true,
        //         color: "#2deaf7",
        //         opacity: 0.6,
        //         outline: true,
        //         outlineWidth: 3,
        //         outlineColor: "#e000d9",
        //         outlineOpacity: 1.0
        //     },
        //     popup: "all",
        //     flyTo: false
        // })
        // map.addLayer(arcGisLayer)
        
        
        $('.click_pop3').click(function () {
            map.flyToPoint([$(this).attr("data-lng"),$(this).attr("data-lat")],{radius:300});
        });
        
        var graphicLayer = new mars3d.layer.GraphicLayer()
        map.addLayer(graphicLayer)
        roamLine = new mars3d.graphic.RoamLine({
            name: "空中漫游",
            timeField: "datatime",
            positions: [
                { lng: 117.676845, lat: 35.039753, alt: 650, datatime: "2021/3/25 0:01:00" },
                { lng: 117.98615, lat: 35.271007, alt: 650, datatime: "2021/3/25 0:010:30" },
                { lng: 118.060026, lat: 35.458449, alt: 650, datatime: "2021/3/25 0:20:10" }
            ],
            camera: {
                type: "dy",
                followedX: 50,
                followedZ: 80
            },
            clockLoop: true, // 是否循环播放
            interpolation: true // setInterpolationOptions插值
        })
        graphicLayer.addGraphic(roamLine)
    
        // 开始漫游
        roamLine.stop()

        
        $.ajax({
            type: "GET",
            url: BASE_URL + "/api/DroneScreenDisplay/GetDroneGeoJson",
            dataType: "json",
            async:false,
            beforeSend: function(xhr) {},
            success: function(data){
				var historyLayer =new mars3d.layer.GeoJsonLayer({
					data:data.result.features,
					symbol: {
						type:"polygon",
						styleOptions: {
						  fill: false,
						  fillColor:"#ff0000",
						  opacity: 0,
						  outline: true,
						  outlineColor: "#ff0000",
						  outlineWidth: 2,
						  outlineOpacity: 1,
						  perPositionHeight: false,
						  clampToGround: true,
						}
					}
				})
				map.addLayer(historyLayer);
            }
        });

    }
)
