123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
- <meta name="author" content="火星科技 http://mars3d.cn " />
- <meta name="apple-touch-fullscreen" content="yes" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <meta name="apple-mobile-web-app-status-bar-style" content="black" />
- <meta name="format-detection" content="telephone=no" />
- <meta name="x5-fullscreen" content="true" />
- <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
- <!-- 标题及搜索关键字 -->
- <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
- <meta
- name="description"
- content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型 gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包 地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
- />
- <link rel="shortcut icon" type="image/x-icon" href="" />
- <title>地理编码查询</title>
- <!--第三方lib-->
- <script
- type="text/javascript"
- src="../lib/include-lib.js"
- libpath="../lib/"
- include="jquery,font-awesome,web-icons,bootstrap,bootstrap-table,bootstrap-checkbox,layer,toastr,haoutil,turf,mars3d"
- ></script>
- <link href="css/style.css" rel="stylesheet" />
- <style>
- .querybar-page {
- margin: 10px 0 0 0;
- font-size: 12px;
- }
- .querybar-ye a {
- text-decoration: none;
- padding: 4px 6px;
- color: #fff;
- border: solid 1px #ccc;
- margin-right: 4px;
- }
- .querybar-ye a:hover {
- color: #fff;
- border-color: #dcdcdc;
- }
- .querybar-fl {
- float: left;
- }
- .querybar-fr {
- float: right;
- }
- </style>
- </head>
- <body class="dark">
- <!--加载前进行操作提示,优化用户体验-->
- <div id="mask" class="signmask" onclick="removeMask()"></div>
- <div id="mars3dContainer" class="mars3d-container"></div>
- <div class="infoview">
- <table class="mars-table">
- <tr>
- <td class="nametd">名称:</td>
- <td>
- <input id="queryText" type="text" placeholder="请输入查询关键字" value="" class="form-control" />
- </td>
- </tr>
- <tr>
- <td class="nametd">范围:</td>
- <td>
- <input type="button" class="btn btn-primary" value="框选范围" id="drawRectangle" />
- <input type="button" class="btn btn-primary" value="圆形范围" id="drawCircle" />
- <input type="button" class="btn btn-primary" value="多边形范围" id="drawPolygon" />
- </td>
- </tr>
- <tr>
- <td class="nametd">范围:</td>
- <td>
- <input type="button" class="btn btn-primary" value="查询" id="query" />
- <input type="button" class="btn btn-primary" value="清除" id="removeAll" />
- </td>
- </tr>
- </table>
- <div id="resultView" style="max-width: 500px; display: none">
- <table id="table" style="table-layout: fixed; word-break: break-all"></table>
- <div class="querybar-page">
- <div class="querybar-fl">找到<strong id="lbl-allCount">0</strong>条结果</div>
- <div class="querybar-ye querybar-fr">
- <span id="lbl-pageIndex">1</span>/<span id="lbl-allPage">1</span>页 <a href="javascript:showFirstPage()">首页</a>
- <a href="javascript:showPretPage()"><</a>
- <a href="javascript:showNextPage()">></a>
- </div>
- </div>
- </div>
- </div>
- <script src="./js/common.js"></script>
- <script type="text/javascript">
- "use script"; //开发环境建议开启严格模式
- var map;
- var queryMapserver;
- var geoJsonLayer;
- var drawGraphic;
- var $table;
- function initMap(options) {
- //合并属性参数,可覆盖config.json中的对应配置
- var mapOptions = mars3d.Util.merge(options, {
- scene: {
- center: { lat: 31.79536, lng: 117.255222, alt: 16294, heading: 358, pitch: -76 },
- },
- });
- //创建三维地球场景
- map = new mars3d.Map("mars3dContainer", mapOptions);
- queryMapserver = new mars3d.query.QueryArcServer({
- url: "//server.mars3d.cn/arcgis/rest/services/mars/hfghss/MapServer/2",
- popup: "all",
- pageSize: 6,
- });
- //用于显示查询结果(geojson)的图层
- geoJsonLayer = new mars3d.layer.GeoJsonLayer({
- symbol: {
- styleOptions: {
- image: "img/marker/mark3.png",
- scale: 1,
- scaleByDistance: true,
- scaleByDistance_far: 20000,
- scaleByDistance_farValue: 0.5,
- scaleByDistance_near: 1000,
- scaleByDistance_nearValue: 1,
- clampToGround: true,
- highlight: { type: "click", image: "img/marker/mark1.png" },
- label: {
- text: "{项目名称}",
- font_size: 25,
- color: "#ffffff",
- outline: true,
- outlineColor: "#000000",
- pixelOffsetY: -25,
- scaleByDistance: true,
- scaleByDistance_far: 80000,
- scaleByDistance_farValue: 0.5,
- scaleByDistance_near: 1000,
- scaleByDistance_nearValue: 1,
- distanceDisplayCondition: true,
- distanceDisplayCondition_far: 80000,
- distanceDisplayCondition_near: 0,
- },
- },
- },
- popup: "all",
- });
- map.addLayer(geoJsonLayer);
- geoJsonLayer.on(mars3d.EventType.load, geoJsonLayer_onLoadHandler);
- //框选查询 多边行
- $("#drawPolygon").click(function () {
- clearAll();
- map.graphicLayer.startDraw({
- type: "polygon",
- style: {
- color: "#00FF00",
- opacity: 0.3,
- outline: true,
- outlineColor: "#ffffff",
- clampToGround: true,
- },
- success: function (graphic) {
- drawGraphic = graphic;
- console.log("多边行:", drawGraphic.toGeoJSON());
- },
- });
- });
- //框选查询 矩形
- $("#drawRectangle").click(function () {
- clearAll();
- map.graphicLayer.startDraw({
- type: "rectangle",
- style: {
- color: "#00FF00",
- opacity: 0.3,
- outline: true,
- outlineColor: "#ffffff",
- clampToGround: true,
- },
- success: function (graphic) {
- drawGraphic = graphic;
- console.log("矩形:", drawGraphic.toGeoJSON({ outline: true }));
- },
- });
- });
- //框选查询 圆
- $("#drawCircle").click(function () {
- clearAll();
- map.graphicLayer.startDraw({
- type: "circle",
- style: {
- color: "#00FF00",
- opacity: 0.3,
- outline: true,
- outlineColor: "#ffffff",
- clampToGround: true,
- },
- success: function (graphic) {
- drawGraphic = graphic;
- console.log("圆:", drawGraphic.toGeoJSON({ outline: true }));
- },
- });
- });
- $("#removeAll").click(function () {
- clearAll();
- });
- $("#query").click(function () {
- queryData();
- });
- $table = $("#table");
- $table.bootstrapTable({
- singleSelect: true, //单选
- iconsPrefix: "fa",
- pagination: false,
- columns: [
- {
- title: "", //序号
- sortable: false,
- align: "center",
- width: 50,
- formatter: function (value, row, index) {
- return index + 1;
- },
- },
- {
- field: "项目名称",
- title: "名称",
- sortable: true,
- width: 100,
- },
- {
- field: "设施类型",
- title: "类型",
- sortable: true,
- align: "center",
- width: 70,
- },
- {
- field: "具体位置",
- title: "地址",
- sortable: true,
- formatter: function (value, row) {
- if (value) {
- return value;
- } else {
- return "";
- }
- },
- },
- ],
- onClickRow: function (item, $element, field) {
- var graphic = item.graphic;
- if (graphic == null) {
- toastr.warning(item.name + " 无经纬度坐标信息!");
- return;
- }
- graphic.openHighlight();
- graphic.flyTo({
- radius: 1000, //点数据:radius控制视距距离
- scale: 1.5, //线面数据:scale控制边界的放大比例
- complete: () => {
- graphic.openPopup();
- },
- });
- },
- });
- }
- function clearAll(noClearDraw) {
- $("#resultView").hide();
- drawGraphic = null;
- map.graphicLayer.clear();
- geoJsonLayer.clear();
- }
- function queryData() {
- $("#resultView").hide();
- var queryVal = $.trim($("#queryText").val());
- queryMapserver.query({
- column: "项目名称",
- text: queryVal,
- graphic: drawGraphic,
- success: (result) => {
- if (result.count == 0) {
- haoutil.msg("未查询到相关记录!");
- return;
- }
- $("#lbl-allCount").html(result.allCount);
- $("#lbl-allPage").html(result.allPage);
- $("#lbl-pageIndex").html(result.pageIndex);
- geoJsonLayer.load({ data: result.geojson });
- },
- error: (error, msg) => {
- console.log("服务访问错误", error);
- haoutil.alert(msg, "服务访问错误");
- },
- });
- }
- function geoJsonLayer_onLoadHandler(event) {
- $table.bootstrapTable("load", event.list);
- $("#resultView").show();
- }
- // 首页
- function showFirstPage() {
- queryMapserver.showFirstPage();
- }
- // 上一页
- function showPretPage() {
- queryMapserver.showPretPage();
- }
- // 下一页
- function showNextPage() {
- queryMapserver.showNextPage();
- }
- </script>
- </body>
- </html>
|