From f95c2cc9d70420202c07d469b49303e7b3b0d094 Mon Sep 17 00:00:00 2001 From: chenhuan <czj123456> Date: 星期五, 17 五月 2024 10:03:05 +0800 Subject: [PATCH] Merge branch 'master' of http://117.78.1.188:8089/r/dkyChenJiang --- javaweb-plus/javaweb-admin/src/main/resources/static/js/custom/main.js | 72 +++++++++++++++++++++++++++-------- 1 files changed, 55 insertions(+), 17 deletions(-) diff --git a/javaweb-plus/javaweb-admin/src/main/resources/static/js/custom/main.js b/javaweb-plus/javaweb-admin/src/main/resources/static/js/custom/main.js index ed593dd..95016c1 100644 --- a/javaweb-plus/javaweb-admin/src/main/resources/static/js/custom/main.js +++ b/javaweb-plus/javaweb-admin/src/main/resources/static/js/custom/main.js @@ -5,6 +5,9 @@ //bindEvent(); }) // 鍔犺浇鍦板浘 +var countries = []; +var countriesOverlay = new T.D3Overlay(init,redraw); +var countriesOverlay1 = new T.D3Overlay(init1,redraw1); function loadMap() { let map = new T.Map('map_div'); map.centerAndZoom(new T.LngLat(116.38, 39.9), 11); @@ -12,25 +15,60 @@ var control = new T.Control.Zoom(); control.setPosition(T_ANCHOR_TOP_RIGHT); map.addControl(control);// 娣诲姞缂╂斁骞崇Щ鎺т欢 - var scale = new T.Control.Scale();// 鍒涘缓姣斾緥灏烘帶浠跺璞� - // var ctrl = new T.Control.MapType(); - // ctrl.setPosition(T_ANCHOR_BOTTOM_RIGHT); - // 娣诲姞鎺т欢 - map.addControl(ctrl); - - - // const sourceGeoJson = new VectorSource({ - // format: new GeoJSON(), - // url:'/beijing.geojson' - // }); - // - // const layerGeoJson = new VectorLayer({ - // source:sourceGeoJson, - // }); - // - // map.addLayer(layerGeoJson); + d3.json("/bjfw/js/custom/beijing.json", function (data) { + countries = data.features; + map.addOverLay(countriesOverlay) + countriesOverlay.bringToBack(); + map.addOverLay(countriesOverlay1) + countriesOverlay.bringToBack(); + }); } + + + +function init(sel, transform) { + var upd = sel.selectAll('path.geojson').data(countries); + upd.enter() + .append('path') + .attr("class", "geojson") + .attr('stroke', 'grey') + .attr('fill', function (d, i) { + //return d3.hsl(Math.random() * 360, 0.9, 0.5) + return "transparent" + }) + .attr('fill-opacity', '0') +} + +function redraw(sel, transform) { + sel.selectAll('path.geojson').each( + function (d, i) { + d3.select(this).attr('d', transform.pathFromGeojson) + } + ) +} + + +function init1(sel, transform) { + var upd = sel.selectAll('path.geojson1').data(countries); + upd.enter() + .append('path') + .attr("class", "geojson1") + .attr('stroke', 'grey') + .attr('fill', function (d, i) { + return d3.hsl(Math.random() * 360, 0.9, 0.5) + }) + .attr('fill-opacity', '0.1') +} + +function redraw1(sel, transform) { + sel.selectAll('path.geojson1').each( + function (d, i) { + d3.select(this).attr('d', transform.pathFromGeojson) + } + ) +} + // 鑾峰彇鏁版嵁搴撶湡瀹炴暟鎹� function getReallyData() { let url = window.location.protocol + "//" + window.location.host + "/bjfw/geotdp/index/indexCollect"; -- Gitblit v1.9.1