123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438 |
- <!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>高德POI点查询 </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 rel="stylesheet" href="../lib/city-picker/city-picker.css" />
- <script src="../lib/city-picker/city-picker.data.js"></script>
- <script src="../lib/city-picker/city-picker.js"></script>
- <link href="css/style.css" rel="stylesheet" />
- <style>
- .city-picker-span {
- display: block;
- margin: 0 auto;
- }
- .form-control {
- max-width: 80%;
- }
- </style>
- </head>
- <body class="dark">
- <!--加载前进行操作提示,优化用户体验-->
- <div id="mask" class="signmask" onclick="removeMask()"></div>
- <div id="mars3dContainer" class="mars3d-container"></div>
- <div class="infoview">
- <div>
- <div>
- <span>范围:</span>
- <div class="radio radio-info radio-inline">
- <input type="radio" id="queryContent1" name="queryContent" value="1" checked />
- <label for="queryContent1">指定城市</label>
- </div>
- <div class="radio radio-info radio-inline">
- <input type="radio" id="queryContent2" name="queryContent" value="2" />
- <label for="queryContent2">当前视域附近</label>
- </div>
- <div class="radio radio-info radio-inline">
- <input type="radio" id="queryContent3" name="queryContent" value="3" />
- <label for="queryContent3">指定范围</label>
- </div>
- </div>
- <div style="position: relative; margin-top: 10px" class="queryByCity">
- <input id="txtCity" readonly type="text" placeholder="请选择城市" style="width: 100%" />
- </div>
- <div class="queryByDraw" style="display: none; margin-top: 10px; text-align: center">
- <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" />
- </div>
- <div style="margin-top: 10px">
- <span>关键字:</span><input id="queryText" type="text" placeholder="查询名称或地址" value="" class="form-control" />
- </div>
- </div>
- <div style="margin-top: 10px; margin-bottom: 10px; text-align: center">
- <input type="button" class="btn btn-primary" value="查询" id="query" />
- <input type="button" class="btn btn-primary" value="清除" id="removeAll" />
- </div>
- <div id="resultView" style="max-width: 500px; display: none">
- <table id="table"></table>
- <div>
- <input type="button" class="btn btn-primary" value="加载更多" id="loadMore" />
- <div style="float: right">
- 大约 <span style="color: red" id="allcount">0</span> 条数据, 已加载 <span style="color: red" id="count"
- >0</span
- > 条数据,
- </div>
- </div>
- </div>
- </div>
- <script src="./js/common.js"></script>
- <script type="text/javascript">
- "use script"; //开发环境建议开启严格模式
- var map;
- var poiLayer;
- var queryGaodePOI;
- var drawGraphic; //限定区域
- var $table;
- var bootstrapList = []; //查询结果
- var lastQueryOptions; //上一次请求参数,用于 下一页使用
- function initMap(options) {
- //合并属性参数,可覆盖config.json中的对应配置
- var mapOptions = mars3d.Util.merge(options, {
- scene: {
- center: { lat: 31.797919, lng: 117.281329, alt: 36236, heading: 358, pitch: -81 },
- },
- });
- //创建三维地球场景
- map = new mars3d.Map("mars3dContainer", mapOptions);
- //创建矢量数据图层
- poiLayer = new mars3d.layer.GraphicLayer();
- map.addLayer(poiLayer);
- poiLayer.bindPopup(function (event) {
- var item = event.graphic.attr;
- var inHtml = '<div class="mars-popup-titile">' + item.name + '</div><div class="mars-popup-content" >';
- var type = $.trim(item.type);
- if (type != "") {
- inHtml += "<div><label>类别</label>" + type + "</div>";
- }
- var xzqh = $.trim(item.xzqh);
- if (xzqh != "") {
- inHtml += "<div><label>区域</label>" + xzqh + "</div>";
- }
- var tel = $.trim(item.tel);
- if (tel != "") {
- inHtml += "<div><label>电话</label>" + tel + "</div>";
- }
- var address = $.trim(item.address);
- if (address != "") {
- inHtml += "<div><label>地址</label>" + address + "</div>";
- }
- inHtml += "</div>";
- return inHtml;
- });
- queryGaodePOI = new mars3d.query.GaodePOI({
- // key: ['ae29a37307840c7ae4a785ac905927e0'],
- });
- bindViewEvent();
- }
- function bindViewEvent() {
- $("#txtCity").citypicker({
- simple: true,
- level: "city",
- province: "安徽省",
- city: "合肥市",
- //district: '蜀山区',
- });
- $table = $("#table");
- $table.bootstrapTable({
- height: 300,
- singleSelect: true, //单选
- pagination: false,
- iconsPrefix: "fa",
- columns: [
- {
- title: "序号",
- sortable: true,
- editable: false,
- align: "left",
- formatter: function (value, row, index) {
- return index + 1;
- },
- },
- {
- field: "name",
- title: "企业名称",
- },
- {
- field: "address",
- title: "地址",
- },
- ],
- onClickRow: function (item, $element, field) {
- var graphic = item._graphic;
- if (graphic == null) {
- toastr.warning(item.name + " 无经纬度坐标信息!");
- return;
- }
- graphic.openHighlight();
- graphic.flyTo({
- radius: 2000, //点数据:radius控制视距距离
- scale: 1.5, //线面数据:scale控制边界的放大比例
- complete: () => {
- graphic.openPopup();
- },
- });
- },
- });
- var selectType;
- $('input:radio[name="queryContent"]').change(function () {
- selectType = $(this).val();
- switch (selectType) {
- default:
- //按城市
- $(".queryByCity").show();
- $(".queryByDraw").hide();
- break;
- case "2": //当前视角范围
- $(".queryByCity").hide();
- $(".queryByDraw").hide();
- break;
- case "3": //按范围
- $(".queryByCity").hide();
- $(".queryByDraw").show();
- break;
- }
- });
- $("#query").click(function () {
- clearAll(selectType == "3");
- bootstrapList = [];
- switch (selectType) {
- default:
- //按城市
- //var dnnm = $('#txtCity').data('citypicker').getCode()
- var dmmc = $("#txtCity").data("citypicker").getName();
- loadData({
- page: 0,
- city: dmmc,
- citylimit: true,
- });
- break;
- case "2": //当前视角范围
- var extent = map.getExtent();
- loadData({
- page: 0,
- polygon: [
- [extent.xmin, extent.ymin],
- [extent.xmax, extent.ymax],
- ],
- limit: true,
- });
- break;
- case "3": //按范围
- if (!drawGraphic) {
- toastr.warning("请绘制限定范围!");
- return;
- }
- loadData({
- page: 0,
- graphic: drawGraphic,
- limit: true,
- });
- break;
- }
- });
- //框选查询 矩形
- $("#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;
- },
- });
- });
- //框选查询 多边
- $("#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;
- },
- });
- });
- //框选查询 圆
- $("#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;
- },
- });
- });
- $("#removeAll").click(function () {
- clearAll();
- });
- //加载更多- 下一页
- $("#loadMore").click(function () {
- if (!lastQueryOptions) {
- return;
- }
- lastQueryOptions.page++;
- loadData(lastQueryOptions);
- });
- }
- function loadData(queryOptions) {
- var queryVal = $.trim($("#queryText").val());
- if (queryVal.length == 0) {
- haoutil.msg("请输入 名称 关键字筛选数据!");
- return;
- }
- haoutil.loading.show();
- lastQueryOptions = {
- ...queryOptions,
- count: 25, //count 每页数量
- text: queryVal,
- success: function (res) {
- $("#resultView").show();
- var data = res.list;
- bootstrapList = bootstrapList.concat(data);
- $table.bootstrapTable("append", data);
- $("#count").html(bootstrapList.length);
- $("#allcount").html(res.allcount);
- if (bootstrapList.length >= res.allcount || res.allcount < 25 || data.length == 0) {
- $("#loadMore").hide();
- } else {
- $("#loadMore").show();
- }
- addGraphics(data);
- haoutil.loading.close();
- },
- error: function (msg, error) {
- window.toastr.error(msg);
- haoutil.loading.close();
- },
- };
- queryGaodePOI.query(lastQueryOptions);
- }
- function clearAll(noClearDraw) {
- lastQueryOptions = null;
- bootstrapList = [];
- $table.bootstrapTable("load", bootstrapList);
- $("#resultView").hide();
- $("#loadMore").hide();
- poiLayer.clear();
- if (!noClearDraw) {
- drawGraphic = null;
- map.graphicLayer.clear();
- }
- }
- function addGraphics(arr) {
- console.log("查询数据结果", arr);
- for (var i = 0; i < arr.length; i++) {
- var item = arr[i];
- var graphic = new mars3d.graphic.BillboardEntity({
- position: Cesium.Cartesian3.fromDegrees(item.lng, item.lat),
- style: {
- 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: item.name,
- font: "20px 楷体",
- color: Cesium.Color.AZURE,
- outline: true,
- outlineColor: Cesium.Color.BLACK,
- outlineWidth: 2,
- horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
- verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
- pixelOffset: new Cesium.Cartesian2(0, -30), //偏移量
- distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0.0, 200000),
- clampToGround: true, //贴地
- },
- },
- attr: item,
- });
- poiLayer.addGraphic(graphic);
- item._graphic = graphic;
- }
- }
- </script>
- </body>
- </html>
|