Explorar o código

江门智慧城市首次提交

wuweihao %!s(int64=4) %!d(string=hai) anos
pai
achega
faf3fa1f0b

BIN=BIN
gmap/src/main/resources/static/aa.jpg


+ 103 - 0
gmap/src/main/resources/static/css/common.css

@@ -0,0 +1,103 @@
+@charset "UTF-8";
+
+/** 清除内外边距 **/
+body
+{ 
+    margin: 0;
+    padding: 0;
+    overflow:hidden;
+}
+
+/** 设置默认字体 **/
+body, button, input, select, textarea { /* for ie */
+    /*font: 12px/1 Tahoma, Helvetica, Arial, "宋体", sans-serif;*/
+    font: 12px / 1 Tahoma, Helvetica, Arial, "\5b8b\4f53", sans-serif; /* 用 ascii 字符表示,使得在任何编码下都无问题 */
+}
+
+input[type =
+"button"], input[type = "submit"] {
+    padding: 0 5px;
+    font-size: 12px;
+    border: #7b9ebd 1px solid;
+    height: 20px;
+    line-height: 20px;
+    /* background: #eee url(../images/btn_bg.gif) center repeat-x; */
+    cursor: pointer;
+    margin: 3px 3px 3px 0;
+}
+
+p {
+    line-height: 20px;
+}
+
+.clear {
+    clear: both;
+}
+
+#gmap {
+    float: left;
+    width: 100%;
+    height: 100%;
+    position: absolute;
+}
+
+#dialog{
+	height:200px;
+	width:240px; 
+	background-color:#ffffff; 
+	border:solid 1px #15589A;
+	position:absolute; 
+	top: 0px;
+	right: 0px;
+	font-size: 12px; 
+	padding-bottom: 5px;
+}
+
+#dialog .dtitle{
+	height:20px;
+	line-height:20px;
+	vertical-align:middle;
+	background-color:#3675AB;
+}
+#switchContainer .dtitle{
+	height:20px;
+	line-height:20px;
+	vertical-align:middle;
+	background-color:#3675AB;
+}
+ #switchContainer {
+    background: #eee;
+    width: 300px;
+    height: 280px;
+    z-index: 10000;
+    position: absolute;
+    margin: 0px 0px;
+    border:solid 1px #15589A;
+    background-color:#ffffff; 
+    font-size: 12px;
+    top: 0px;
+	right: 0px;
+}
+#switchContainer .bgiframe {
+    /**filter: Alpha(Opacity = '0');*/
+    width: 300px;
+    height: 280px;
+    z-index: -1;
+    position: absolute;
+    top: 0px;
+	right: 0px;
+}
+
+.olImageLoadError{ 
+	background-color: pink; 
+	opacity: 0!important; 
+	filter: alpha(opacity=0)!important; 
+}
+.olControlOverviewMapMaximizeButton{bottom:0!important;}
+.olControlOverviewMapMinimizeButton{bottom:0!important;}
+/* 鹰眼样式 */  
+.olControlOverviewMapElement {   
+    background-color: #3675AB!important;   
+    border-top: 2px solid #ccc;   
+    border-left: 2px solid #ccc;   
+ } 

+ 56 - 0
gmap/src/main/resources/static/css/index.css

@@ -0,0 +1,56 @@
+#dcontent>div{
+    margin: 10px;
+}
+#serviceTable{
+    width: 100%;
+}
+#serviceTable td{
+    text-align: center;
+}
+
+.geocodingPanel{
+    display: none;
+}
+
+#service{
+    width: 60%;
+}
+
+#geoCodingUrl{
+    width: 70%;
+}
+
+#geoCodingUrlPanel{
+    margin-top: 10px;
+}
+
+#loadServicesPanel{
+    margin-top: 20px;
+    text-align: center;
+}
+
+#loadServices{
+    height: 30px;
+}
+
+#busUrlPanel{
+    margin-top: 20px;
+}
+
+#busUrl{
+    width: 70%
+}
+
+#zoom{
+    position: absolute;
+    background: #fff;
+    bottom: 150px;
+    right: 10px;
+    font-size: 18px;
+    text-align: center;
+    padding: 8px;
+    color: #fff;
+    box-shadow: 2px 2px 3px rgba(0,0,0,0.1);
+    text-shadow: #4e8cf4 1.5px 0 0, #4e8cf4 0 1.5px 0, #4e8cf4 -1.5px 0 0, #4e8cf4 0 -1.5px 0, #4e8cf4 1px 1px 0, #4e8cf4 -1px 1px 0, #4e8cf4 1px -1px 0, #4e8cf4 -1px -1px 0;
+    cursor: pointer;
+}

BIN=BIN
gmap/src/main/resources/static/img/0.png


BIN=BIN
gmap/src/main/resources/static/img/1.png


BIN=BIN
gmap/src/main/resources/static/img/2.png


BIN=BIN
gmap/src/main/resources/static/img/closeD.png


BIN=BIN
gmap/src/main/resources/static/img/openD.png


BIN=BIN
gmap/src/main/resources/static/img/pin.png


+ 168 - 0
gmap/src/main/resources/static/index.html

@@ -0,0 +1,168 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+	<meta charset="UTF-8">
+	<title>粤政图服务接入示范用例</title>
+	<meta http-equiv="cache-control" content="no-cache">
+	<meta http-equiv="expires" content="0">
+
+	<link href="./lib/mapbox/css/mapbox-gl.css" rel="stylesheet" type="text/css" />
+	<link href="./css/common.css" rel="stylesheet" type="text/css" />
+	<link href="./css/index.css" rel="stylesheet" type="text/css" />
+</head>
+
+<body>
+	<div id="gmap"></div>
+
+	<div id="dialog" style="height: auto; width: 500px;">
+		<div class="dtitle">
+			<table cellspacing="0" cellpadding="0" width="100%">
+				<tbody>
+					<tr>
+						<td style="color: #ffffff; font-weight: bold">地图产品接入管理</td>
+						<td style="text-align: right"> <img style="cursor:hand" onclick="slideToggleDialog('dialog')"
+								src="./img/closeD.png"> </td>
+					</tr>
+				</tbody>
+			</table>
+		</div>
+		<div id="dcontent" style="height: auto; overflow: auto; max-height: 500px; display: block;">
+			<div>
+				<span>PaasId:</span>
+				<input id="paasId">
+				<span>PaasToken:</span>
+				<input id="paasToken">
+			</div>
+			<div style="color:red">(温馨提示:地图产品接入业务系统使用时,建议将PaasId与PassToken通过后台配置读取,不通过前端参数传递,避免信息泄露)</div>
+			<div id="serverLoadModeDiv">
+				<span>地图产品接入模式:</span>
+				<select id="modeType">
+					<option value="bus">数据中台</option>
+					<option value="gateway">智能网关</option>
+				</select>
+			</div>
+			
+			<div id="busUrlPanel">
+				<span>数据中台接口地址:</span>
+				<input id="busUrl">
+			</div>
+
+			<div id="typeDiv">
+				<span>地图产品类型:</span>
+				<select id="typeSelect">
+					<option value="wmts">地图服务</option>
+					<option value="wfs">要素服务</option>
+					<option value="geocoding">地名地址服务</option>
+				</select>
+			</div>
+
+			<div class="serverOpPanel">
+				<div>
+					<span class="serverTipName">服务:</span>
+					<input id="service">
+					<button id="addService">添加</button>
+				</div>
+				<div style="margin:10px" class="wfsResultTypePanel">
+					<span>返回数据类型:</span>
+					<input name="resultType" type="radio" value="XML" checked="checked">XML
+					<input name="resultType" type="radio" value="GEOJSON">GEOJSON
+				</div>
+				<div>
+					<table id="serviceTable">
+						<thead>
+							<tr class="wmtsTr">
+								<th width="80%">地图产品</th>
+								<th width="20%">操作</th>
+							</tr>
+							<tr class="wfsTr" style="display: none;">
+								<th width="60%">地图产品</th>
+								<th width="20%">返回数据类型</th>
+								<th width="20%">操作</th>
+							</tr>
+						</thead>
+						<tbody>
+						</tbody>
+					</table>
+				</div>
+				<div id="loadServicesPanel">
+					<button id="loadServices">加载至地图</button>
+				</div>
+			</div>
+
+			<div class="geocodingPanel">
+				<div style="margin-top: 10px;">
+					<span>地名地址查询方式:</span>
+					<select id="geoCodingType">
+						<option value="addrToLoc">正向匹配</option>
+						<option value="locToaddr">反向匹配</option>
+					</select>
+				</div>
+				
+				<div id="geoCodingUrlPanel">
+					<span class="serverTipName">服务:</span>
+					<input id="geoCodingUrl">
+				</div>
+
+				<!-- 正向匹配 -->
+				<div class="geocodingDiv" id="addrToLocDiv" style="text-align:height:auto;width:350px;overflow:auto;max-height:500px;">
+					<br />
+					<TABLE align="center" cellSpacing="0" cellPadding="1" width="90%" style="line-height:1.5">
+						<TR>
+							<TD>本示例演示地址正向匹配,并且关联查询出该地址上的POI</TD>
+						</TR>
+						<TR>
+							<TD style="height: 30px;"> <input type="text" id="addrToLocQueryText" value="广东省人民政府" style="width:200px;" /> &nbsp;&nbsp;
+								<input type="button" value="查询" id="addrToLoc"/>
+							</TD>
+						</TR>
+						<TR>
+							<td style="height: 30px;">
+								<input type="checkbox" name="params" id="trd" style="vertical-align:middle" checked  />地址关联POI&nbsp;
+							</td>
+						</TR>
+						<TR>
+							<TD> <div id="addrToLocDIVresult"></div>
+							</TD>
+						</TR>
+					</TABLE>
+				</div>
+		
+				<!-- 反向匹配 -->
+				<div class="geocodingDiv" id="locToaddrDiv" style="text-align:height:auto;width:350px;overflow:auto;max-height:500px;display:none">
+					<br />
+					<TABLE align="center" cellSpacing="0" cellPadding="1" width="90%" style="line-height:1.5">
+						<TR>
+							<TD>本示例演示根据坐标反向查询地名</TD>
+						</TR>
+						<TR>
+							<TD style="height: 30px;"> <input type="text" id="locToAddrQueryText" value="113.2612197650001,23.135719477000071"
+									style="width:220px;" /> &nbsp;&nbsp;
+								<input type="button" value="查询" id="locToAddr"/>
+							</TD>
+						</TR>
+						<TR>
+							<TD>
+								<div id="locToAddrDIVresult"></div>
+							</TD>
+						</TR>
+					</TABLE>
+				</div>
+			</div>
+		</div>
+	</div>
+
+	<div id="zoom"></div>
+</body>
+<script type="text/javascript" src="./lib/jQuery/jquery-3.4.1.js"></script>
+<script type="text/javascript" src="./js/Tianditu.js"></script>
+<script type="text/javascript" src="./map/js/urlUtil.js"></script>
+<script type="text/javascript" src="./lib/mapbox/js/mapbox-gl.js"></script>
+<script type="text/javascript" src="./lib/GeoGlobeSDK/GeoGlobeJS.min.js"></script>
+<script type="text/javascript" src="./map/js/wmtsUtil.js"></script>
+<script type="text/javascript" src="./map/js/wfsUtil.js"></script>
+<script type="text/javascript" src="./map/js/geocodingUtil.js"></script>
+<script type="text/javascript" src="./map/js/mapView.js"></script>
+<script type="text/javascript" src="./map/js/index.js"></script>
+
+</html>

+ 228 - 0
gmap/src/main/resources/static/openlayers-api/wfsQueryLayer.html

@@ -0,0 +1,228 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <title>Openlayers要素服务加载</title>
+    <link rel="stylesheet"
+        href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.4.3/css/ol.css">
+    <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
+    <script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.4.3/build/ol.js"></script>
+    <script src="../js/Tianditu.js"></script>
+    <style type="text/css">
+        #map {
+            position: absolute;
+            width: 100%;
+            height: 100%;
+            left: 0;
+            top: 0;
+        }
+
+        .selected-panel {
+            position: absolute;
+            right: 0px;
+            width: 230px;
+            height: 65px;
+            background: #ffffff;
+            z-index: 1;
+        }
+    </style>
+</head>
+
+<body>
+    <div class="selected-panel">
+        <div style="padding: 20px;">
+            <label for="">选择要素类型:</label>
+            <select name="" id="typeSelect">
+                <option value="点要素">点要素</option>
+                <option value="线要素">线要素</option>
+                <option value="面要素">面要素</option>
+            </select>
+        </div>
+    </div>
+    <div id="map" class="map"></div>
+    <script>
+        var layerUrl = {
+            gdLayerUrl: "/gmap/gateway/geostar/GD_2018DLG/wmts",
+            gdAnnoLayerUrl: "/gmap/gateway/geostar/GD_2018DLGZJ/wmts",
+            polygonWfsUrl: "/gmap/gateway/geostar/GZSXJXZQHM_wfs/wfs",//面要素
+            pointWfsUrl: "/gmap/gateway/geostar/GD_SJJYZ/wfs",//点要素
+            lineWfsUrl: "/gmap/gateway/geostar/JTYST_GSGL2019/wfs" //线要素
+        }
+        var projection = new ol.proj.Projection({
+            code: 'EPSG:4490',
+            units: 'degrees'
+        });
+        var projectionExtent = [-180, -90, 180, 90];
+        var size = ol.extent.getWidth(projectionExtent) / 256;
+        var resolutions = [];
+        for (var z = 2; z < 19; ++z) {
+            resolutions[z] = size / Math.pow(2, z);
+        }
+        var vectorSource = new ol.source.Vector();
+        var vectorLayer = new ol.layer.Vector({
+            source: vectorSource
+        });
+
+        var map = new ol.Map({
+            layers: [
+                new ol.layer.Tile({
+                    source: getWMTSLayer(layerUrl.gdLayerUrl)
+                }),
+                new ol.layer.Tile({
+                    source: getWMTSLayer(layerUrl.gdAnnoLayerUrl)
+                }),
+                vectorLayer
+
+            ],
+            target: "map",
+            view: new ol.View({
+                center: [113.679943564, 22.559617265],
+                projection: projection,
+                zoom: 8,
+                maxZoom: 17,
+                minZoom: 1
+            })
+        });
+
+        function getWMTSLayer(serviceUrl) {
+            var xml = getCapabilities(serviceUrl);
+            var format = new ol.format.WMTSCapabilities();
+            var geojson = format.read(xml.documentElement);
+            var data = geojson.Contents.Layer[0];
+            var layerParam = {
+                layerName: data.Abstract,
+                styleName: data.Style[0].Identifier,
+                tilematrixset: data.TileMatrixSetLink[0].TileMatrixSet,
+                format: data.Format[0]
+            };
+            var source = new ol.source.WMTS({
+                url: serviceUrl,
+                layer: layerParam.layerName,
+                style: layerParam.styleName,
+                matrixSet: layerParam.tilematrixset,
+                format: layerParam.format,
+                wrapX: true,
+                tileGrid: new ol.tilegrid.WMTS({
+                    origin: ol.extent.getTopLeft(projectionExtent),
+                    resolutions: resolutions,
+                    matrixIds: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
+                })
+            });
+            return source;
+        }
+
+        var fill = new ol.style.Fill({
+            color: 'rgba(255,0,0,0.4)'
+        });
+        var image = new ol.style.Circle({
+            radius: 5,
+            fill: fill,
+            stroke: new ol.style.Stroke({ color: 'red', width: 3 }),
+        });
+        var format = new ol.format.GML2();
+        var pointQueryXml = '<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" maxFeatures="999999" ' +
+            'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
+            'xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd">' +
+            '<wfs:Query typeName="广东省际检疫站" userecent="true" /></wfs:GetFeature>';
+        queryWfsLayer(pointQueryXml, layerUrl.pointWfsUrl, function (result) {
+            var features = format.readFeatures(result);
+            vectorSource.addFeatures(features);
+            vectorLayer.setStyle(new ol.style.Style({
+                image: image,
+            }));
+        });
+        //获取地图服务图层信息
+        function getCapabilities(serviceUrl) {
+            var xml;
+            $.ajax({
+                type: "get",
+                url: serviceUrl + "?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities",
+                async: false,
+                success: function (result) {
+                    xml = result;
+                }
+            });
+            return xml;
+        }
+
+        $(document).on("change", "#typeSelect", function () {
+            var wfsType = $("#typeSelect").val();
+            if (wfsType == "点要素") {
+                queryWfsLayer(pointQueryXml, layerUrl.pointWfsUrl, function (result) {
+                    var features = format.readFeatures(result);
+                    vectorSource.addFeatures(features);
+                    vectorLayer.setStyle(new ol.style.Style({
+                        image: image,
+                    }));
+                });
+            } else if (wfsType == "线要素") {
+                // var featureRequest = new ol.format.WFS().writeGetFeature({
+                //     srsName: 'EPSG:4490',
+                //     featureTypes: ['JTYST_GSGL2019'],
+                //     filter: ol.format.filter.like('XZQH', '4401*')
+                // });
+                var polylineQueryXml = '<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" maxFeatures="999999" ' +
+                    'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd">' +
+                    '<wfs:Query typeName="JTYST_GSGL2019" srsName="EPSG:4490">' +
+                    '<Filter xmlns="http://www.opengis.net/ogc">' +
+                    '<PropertyIsLike wildCard="*" singleChar="." escapeChar="!">' +
+                    '<PropertyName>XZQH</PropertyName>' +
+                    '<Literal>4401*</Literal>' +
+                    '</PropertyIsLike>' +
+                    '</Filter>' +
+                    '</wfs:Query>' +
+                    '</wfs:GetFeature>';
+                queryWfsLayer(polylineQueryXml, layerUrl.lineWfsUrl, function (result) {
+                    var features = format.readFeatures(result);
+                    vectorSource.addFeatures(features);
+                    vectorLayer.setStyle(
+                        new ol.style.Style({
+                            stroke: new ol.style.Stroke({
+                                color: 'red',
+                                width: 4,
+                            }),
+                        })
+                    );
+                });
+            } else if (wfsType == "面要素") {
+                var polygonQueryXml = '<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" maxFeatures="999999" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd">' +
+                    '<wfs:Query typeName="GZSXJXZQHM" srsName="EPSG:4490">' +
+                    '<Filter xmlns="http://www.opengis.net/ogc">' +
+                    '<PropertyIsLike wildCard="*" singleChar="." escapeChar="!">' +
+                    '<PropertyName>XZQDM</PropertyName>' +
+                    '<Literal>4401*</Literal>' +
+                    '</PropertyIsLike>' +
+                    '</Filter>' +
+                    '</wfs:Query>' +
+                    '</wfs:GetFeature>';
+                queryWfsLayer(polygonQueryXml, layerUrl.polygonWfsUrl, function (result) {
+                    var features = format.readFeatures(result);
+                    vectorSource.addFeatures(features);
+                    vectorLayer.setStyle(new ol.style.Style({
+                        stroke: new ol.style.Stroke({
+                            color: 'blue',
+                            width: 2,
+                        }),
+                        fill: fill,
+                    }));
+                });
+            }
+        })
+
+        function queryWfsLayer(queryXml, serviceUrl, callback) {
+            $.ajax({
+                type: "post",
+                url: serviceUrl,
+                //data: new XMLSerializer().serializeToString(featureRequest),
+                data: queryXml,
+                async: false,
+                success: function (result) {
+                    callback(result);
+                }
+            });
+        }
+    </script>
+</body>
+
+</html>

+ 103 - 0
gmap/src/main/resources/static/openlayers-api/wmtsLayer.html

@@ -0,0 +1,103 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Openlayers地图服务加载</title>
+    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.4.3/css/ol.css">
+    <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
+    <script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.4.3/build/ol.js"></script>
+    <script src="../js/Tianditu.js"></script>
+    <style type="text/css">
+        #map {
+            position: absolute;
+            width: 100%;
+            height: 100%;
+            left: 0;
+            top: 0;
+        }
+    </style>
+</head>
+<body>
+<div id="map" class="map"></div>
+<script>
+     var layerUrl = {
+        gdLayerUrl: "/gmap/gateway/geostar/GD_2018DLG/wmts",
+        gdAnnoLayerUrl: "/gmap/gateway/geostar/GD_2018DLGZJ/wmts",
+        wmtsLayerUrl: "/gmap/gateway/geostar/GD_STLSZDFZ/wmts"
+    }
+    var projection = new ol.proj.Projection({  
+        code: 'EPSG:4490',  
+        units: 'degrees' 
+    }); 
+    var projectionExtent = [ -180, -90, 180, 90 ];
+    var size = ol.extent.getWidth(projectionExtent) / 256;
+    var resolutions = [];
+    for (var z = 2; z < 19; ++z) {
+        resolutions[z] = size / Math.pow(2, z);
+    }
+    var map = new ol.Map({
+        layers: [
+            new ol.layer.Tile({
+                source: getWMTSLayer(layerUrl.gdLayerUrl)
+            }),
+            new ol.layer.Tile({
+                source: getWMTSLayer(layerUrl.gdAnnoLayerUrl)
+            }),
+            new ol.layer.Tile({
+                source: getWMTSLayer(layerUrl.wmtsLayerUrl)
+            }),
+ 
+        ],
+        target: "map",
+        view: new ol.View({
+            center: [113.679943564,22.559617265],
+            projection: projection,
+            zoom: 8,
+            maxZoom: 17,
+            minZoom: 1
+        })
+    });
+
+    function getWMTSLayer(serviceUrl){
+    	var xml = getCapabilities(serviceUrl);
+        var format = new ol.format.WMTSCapabilities();
+        var geojson = format.read(xml.documentElement);
+        var data = geojson.Contents.Layer[0];
+        var layerParam = {
+            layerName: data.Abstract,
+            styleName: data.Style[0].Identifier,
+            tilematrixset: data.TileMatrixSetLink[0].TileMatrixSet,
+            format: data.Format[0]
+        };
+        var source = new ol.source.WMTS({
+            url: serviceUrl,
+            layer: layerParam.layerName,
+            style: layerParam.styleName,
+            matrixSet: layerParam.tilematrixset,
+            format: layerParam.format,
+            wrapX: true,
+            tileGrid: new ol.tilegrid.WMTS({
+                origin: ol.extent.getTopLeft(projectionExtent),
+                resolutions: resolutions,
+                matrixIds: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
+            })
+        });
+        return source;
+    }
+
+    //获取地图服务图层信息
+    function getCapabilities(serviceUrl){
+        var xml;
+        $.ajax({
+            type: "get",
+            url: serviceUrl + "?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities",
+            async: false,
+            success: function(result){
+                xml = result;
+            }
+        });
+        return xml;
+    }
+</script>
+</body>
+</html>