123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title data-i18n="resources.title_DatasourceInfo"></title>
- <script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
- <style type="text/css">
- body {
- margin: 0;
- overflow: hidden;
- background: #fff;
- width: 100%;
- height: 100%
- }
- #map {
- position: absolute;
- width: 100%;
- height: 100%;
- }
- #toolbar {
- position: absolute;
- top: 50px;
- right: 10px;
- width: 300px;
- text-align: center;
- z-index: 100;
- border-radius: 4px;
- }
- /* 用户自定义-弹框内容样式 */
- #pop-content {
- right: 0 !important;
- padding-left: 20px;
- color: #000;
- word-wrap: break-word;
- margin-top: 10px;
- }
- </style>
- </head>
- <body>
- <div id="toolbar" class="panel panel-primary">
- <div class='panel-heading'>
- <h5 class='panel-title text-center' data-i18n="resources.title_DatasourceInfo"></h5>
- </div>
- <div class='panel-body content'>
- <div class='panel'>
- <div class='input-group'>
- <span class='input-group-addon' data-i18n="resources.text_Datasources"></span>
- <select id='datasourcesSelect' class='form-control'></select>
- </div>
- </div>
- <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_query"
- onclick="datasourcesPrint()" />
- </div>
- </div>
- <div id="map"></div>
- <script type="text/javascript" include="infoWindow" src="../../dist/classic/include-classic.js"></script>
- <script>
- let host = window.isLocal ? window.server : "https://iserver.supermap.io";
- let map, layer,datasourcesSelect,
- url1 = host + "/iserver/services/map-world/rest/maps/World",
- url2 = host + "/iserver/services/data-world/rest/data";
- init()
- function init() {
- map = new SuperMap.Map("map", {
- controls: [
- new SuperMap.Control.Zoom(),
- new SuperMap.Control.Navigation({
- dragPanOptions: {
- enableKinetic: true
- }
- })]
- });
- layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url1, {
- transparent: true, cacheEnabled: true
- }, { maxResolution: "auto" });
- layer.events.on({ "layerInitialized": addLayer });
- //初始化popup类
- markerPop = new SuperMap.InfoWindow(
- "marker",
- resources.text_featureInfo
- );
- }
- function addLayer() {
- map.addLayers([layer]);
- map.setCenter(new SuperMap.LonLat(0, 0), 0);
- dataSourcesService();
- }
- function dataSourcesService() {
- new SuperMap.REST.DatasourceService(url2).getDatasources(function (serviceResult) {
- datasourcesSelect = document.getElementById("datasourcesSelect");
- const datasourceNames = serviceResult.result.datasourceNames;
- for (let i = 0, len = datasourceNames.length; i < len; i++) {
- datasourcesSelect.options[i] = new Option(datasourceNames[i], datasourceNames[i]);
- }
- });
- }
- //打印数据源信息
- function datasourcesPrint() {
- const datasourceName = datasourcesSelect.value;
- new SuperMap.REST.DatasourceService(url2).getDatasource(datasourceName, function (serviceResult) {
- markerPop.hide();
- markerPop.titleBox = true;
- markerPop.contentSize = new SuperMap.Size(240, 150);
- markerPop.render();
- markerPop.setContentHTML(null, '<div id="pop-content">' + "(" + resources.text_datasourceInfoPrint + ")" + "<br>" +
- "coordUnit:" + JSON.stringify(serviceResult.result.datasourceInfo.coordUnit, null, 2) + "<br>" +
- "description:" + JSON.stringify(serviceResult.result.datasourceInfo.description, null, 2) + "<br>" +
- "distanceUnit:" + JSON.stringify(serviceResult.result.datasourceInfo.distanceUnit, null, 2) + "<br>" +
- "engineType:" + JSON.stringify(serviceResult.result.datasourceInfo.engineType, null, 2) + "<br>" +
- "prjCoordSys:" + "(...)" + "<br>" +
- "name:" + JSON.stringify(serviceResult.result.datasourceInfo.name, null, 2) + "<br></div>")
- markerPop.setLonLat(map.getCenter(), { x: 0, y: 0 });
- //添加弹窗到map图层
- map.addPopup(markerPop)
- });
- }
- // Feature取消选中事件响应
- function onFeatureUnselect() {
- markerPop.destroy();
- }
- </script>
- </body>
- </html>
|