diff --git a/basic-interface/src/main/java/ink/wgink/interfaces/consts/IGisConstant.java b/basic-interface/src/main/java/ink/wgink/interfaces/consts/IGisConstant.java new file mode 100644 index 00000000..00ccac38 --- /dev/null +++ b/basic-interface/src/main/java/ink/wgink/interfaces/consts/IGisConstant.java @@ -0,0 +1,11 @@ +package ink.wgink.interfaces.consts; + +public interface IGisConstant { + + String GIS_MAP_CENTER_LAT = "gisMapCenterLat"; + String GIS_MAP_CENTER_LNG = "gisMapCenterLng"; + String GIS_MAP_CENTER_ZOOM = "gisMapCenterZoom"; + String GIS_MAP_BAIDU_BOUNDARY = "gisMapBaiduBoundary"; + String GIS_MAP_BAIDU_AK = "gisMapBaiduAk"; + +} diff --git a/module-map/src/main/java/ink/wgink/module/map/controller/route/grid/GridRouteController.java b/module-map/src/main/java/ink/wgink/module/map/controller/route/grid/GridRouteController.java index c0f1bbdb..2664aa7b 100644 --- a/module-map/src/main/java/ink/wgink/module/map/controller/route/grid/GridRouteController.java +++ b/module-map/src/main/java/ink/wgink/module/map/controller/route/grid/GridRouteController.java @@ -1,14 +1,17 @@ package ink.wgink.module.map.controller.route.grid; +import ink.wgink.common.manager.env.EnvManager; +import ink.wgink.interfaces.consts.IGisConstant; import ink.wgink.interfaces.consts.ISystemConstant; -import ink.wgink.properties.map.BaiduMapProperties; import io.swagger.annotations.Api; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; +import java.util.HashMap; +import java.util.Map; + /** * @ClassName: GridRouteController * @Description: 网格路由 @@ -21,34 +24,31 @@ import org.springframework.web.servlet.ModelAndView; @RequestMapping(ISystemConstant.ROUTE_PREFIX + "/grid") public class GridRouteController { - @Autowired - private BaiduMapProperties baiduMapProperties; - @GetMapping("save") public ModelAndView save() { ModelAndView mv = new ModelAndView("grid/grid/default/save"); - mv.addObject("baiduMapProperties", baiduMapProperties); + setConfig(mv); return mv; } @GetMapping("update") public ModelAndView update() { ModelAndView mv = new ModelAndView("grid/grid/default/update"); - mv.addObject("baiduMapProperties", baiduMapProperties); + setConfig(mv); return mv; } @GetMapping("get") public ModelAndView get() { ModelAndView mv = new ModelAndView("grid/grid/default/get"); - mv.addObject("baiduMapProperties", baiduMapProperties); + setConfig(mv); return mv; } @GetMapping("show-grid") public ModelAndView showGrid() { ModelAndView mv = new ModelAndView("grid/grid/default/show-grid"); - mv.addObject("baiduMapProperties", baiduMapProperties); + setConfig(mv); return mv; } @@ -62,4 +62,15 @@ public class GridRouteController { return new ModelAndView("grid/grid/default/list-select"); } + private void setConfig(ModelAndView modelAndView) { + EnvManager envManager = EnvManager.getInstance(); + Map baiduMapProperties = new HashMap<>(5); + baiduMapProperties.put("centerLng", envManager.getValue(IGisConstant.GIS_MAP_CENTER_LNG)); + baiduMapProperties.put("centerLat", envManager.getValue(IGisConstant.GIS_MAP_CENTER_LAT)); + baiduMapProperties.put("zoom", envManager.getValue(IGisConstant.GIS_MAP_CENTER_ZOOM)); + baiduMapProperties.put("boundary", envManager.getValue(IGisConstant.GIS_MAP_BAIDU_BOUNDARY)); + baiduMapProperties.put("ak", envManager.getValue(IGisConstant.GIS_MAP_BAIDU_AK)); + modelAndView.addObject("baiduMapProperties", baiduMapProperties); + } + } diff --git a/module-map/src/main/resources/static/baidu-map/baidu-map-1.0.0.min.js b/module-map/src/main/resources/static/baidu-map/baidu-map-1.0.0.min.js index 61fba3bf..c5456c6f 100644 --- a/module-map/src/main/resources/static/baidu-map/baidu-map-1.0.0.min.js +++ b/module-map/src/main/resources/static/baidu-map/baidu-map-1.0.0.min.js @@ -676,35 +676,54 @@ BaiduMap.prototype.initBackgroundGrid = function (option) { }); } - for (var i = 0, backgroundGrid; backgroundGrid = option.gridArray[i++];) { - var polygon = new BMap.Polygon(backgroundGrid.pointArray, { - strokeColor: self.gridOption.const.STROKE_BACKGROUND_COLOR, - strokeWeight: self.gridOption.const.STROKE_BACKGROUND_WEIGHT, - strokeOpacity: self.gridOption.const.STROKE_BACKGROUND_OPACITY, - fillOpacity: self.gridOption.const.FILL_BACKGROUND_OPACITY, - }); - if (backgroundGrid.fillColor) { - polygon.setFillColor(backgroundGrid.fillColor); - } else { - polygon.setFillColor(self.gridOption.const.FILL_BACKGROUND_COLOR); - } - // 添加点击事件 - self.map.addOverlay(polygon); - addClickEvent(polygon, backgroundGrid); - if (!backgroundGrid.label) { - continue; - } - var label = new BMap.Label(backgroundGrid.label); - label.setStyle({ - border: 'none', - backgroundColor: 'transparent', - textShadow: '1px 1px 1px #fff, -1px -1px 1px #fff, 1px -1px 1px #fff, -1px 1px 1px #fff', - fontSize: self.gridOption.const.LABEL_FONT_SIZE + 'px' - }); - label.setOffset(new BMap.Size(-backgroundGrid.label.length * self.gridOption.const.LABEL_FONT_SIZE / 2, -self.gridOption.const.LABEL_FONT_SIZE / 2)); - label.setPosition(self.getCenterPoint(backgroundGrid.pointArray)); - self.labelArray.push(label); - self.map.addOverlay(label); + function draw(page, pageCount, pageSize) { + setTimeout(function() { + var size = page < pageCount ? pageSize : option.gridArray.length - (pageCount - 1) * pageSize; + for(var i = 0; i < size; i++) { + var backgroundGrid = option.gridArray[i + (page - 1) * pageSize]; + var polygon = new BMap.Polygon(backgroundGrid.pointArray, { + strokeColor: self.gridOption.const.STROKE_BACKGROUND_COLOR, + strokeWeight: self.gridOption.const.STROKE_BACKGROUND_WEIGHT, + strokeOpacity: self.gridOption.const.STROKE_BACKGROUND_OPACITY, + fillOpacity: self.gridOption.const.FILL_BACKGROUND_OPACITY, + }); + if (backgroundGrid.fillColor) { + polygon.setFillColor(backgroundGrid.fillColor); + } else { + polygon.setFillColor(self.gridOption.const.FILL_BACKGROUND_COLOR); + } + // 添加点击事件 + self.map.addOverlay(polygon); + addClickEvent(polygon, backgroundGrid); + if (!backgroundGrid.label) { + continue; + } + var label = new BMap.Label(backgroundGrid.label); + label.setStyle({ + border: 'none', + backgroundColor: 'transparent', + textShadow: '1px 1px 1px #fff, -1px -1px 1px #fff, 1px -1px 1px #fff, -1px 1px 1px #fff', + display: 'none', + fontSize: self.gridOption.const.LABEL_FONT_SIZE + 'px' + }); + label.setOffset(new BMap.Size(-backgroundGrid.label.length * self.gridOption.const.LABEL_FONT_SIZE / 2, -self.gridOption.const.LABEL_FONT_SIZE / 2)); + label.setPosition(self.getCenterPoint(backgroundGrid.pointArray)); + self.labelArray.push(label); + self.map.addOverlay(label); + } + if(page < pageCount) { + console.log('加载中...') + } else { + console.log('加载完成') + } + }, page * 50) + } + + // 分页加载,100页 + var pageSize = 10; + var pageCount = option.gridArray.length % pageSize === 0 ? parseInt(option.gridArray.length / pageSize) : parseInt(option.gridArray.length / pageSize) + 1; + for (var page = 1; page <= pageCount; page++) { + draw(page, pageCount, pageSize); } } // 设置开始标记 diff --git a/module-map/src/main/resources/templates/grid/grid/default/get.html b/module-map/src/main/resources/templates/grid/grid/default/get.html index 441720e6..ce59f972 100644 --- a/module-map/src/main/resources/templates/grid/grid/default/get.html +++ b/module-map/src/main/resources/templates/grid/grid/default/get.html @@ -25,8 +25,8 @@ - - + + - + + - + + - + +