Skip to content

Commit

Permalink
feat: 超图supermapgis
Browse files Browse the repository at this point in the history
  • Loading branch information
wkylin committed Sep 19, 2024
1 parent 39bba26 commit 150aa2c
Show file tree
Hide file tree
Showing 8 changed files with 5,492 additions and 63 deletions.
5 changes: 5 additions & 0 deletions .cspell/custom-dictionary-workspace.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ Bookstory
codepaths
CRACO
ENOENT
EPSG
fengian
fengxian
hookspath
Huksy
iclient
markercluster
packagehash
preid
premajor
Expand All @@ -18,6 +21,8 @@ Qube
singleline
snyk
Snyk
spiderfy
supermapgis
teambit
treee
tsbuildinfo
Expand Down
5,426 changes: 5,363 additions & 63 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@
"@sentry/react": "^8.18.0",
"@sentry/tracing": "^7.118.0",
"@types/three": "^0.166.0",
"@supermapgis/iclient-leaflet": "^11.2.0",
"@welldone-software/why-did-you-render": "^8.0.3",
"leaflet": "^1.9.4",
"leaflet.markercluster": "^1.5.3",
"antd": "^5.18.3",
"axios": "^1.7.4",
"blueimp-md5": "^2.19.0",
Expand Down
1 change: 1 addition & 0 deletions src/pages/layout/proSecNav/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const ProSecNav = () => {
{ label: 'ReactAmap', key: '/react-amap', icon: <QrcodeOutlined /> },
{ label: 'PostMessage', key: '/postmessage', icon: <FireOutlined /> },
{ label: 'GeoChart', key: '/geo', icon: <QrcodeOutlined /> },
{ label: 'SuperMap', key: '/super-map', icon: <FireOutlined /> },
{
label: '技术栈',
key: '/sub-act',
Expand Down
Binary file added src/pages/superMap/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
107 changes: 107 additions & 0 deletions src/pages/superMap/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import React, { useEffect, useRef } from 'react'
import L from 'leaflet'
import { TiledMapLayer } from '@supermapgis/iclient-leaflet'
import 'leaflet/dist/leaflet.css'
import 'leaflet.markercluster/dist/leaflet.markercluster-src.js'
import 'leaflet.markercluster/dist/MarkerCluster.css'
import 'leaflet.markercluster/dist/MarkerCluster.Default.css'
import markerIcon from './icon.png'

import styles from './index.module.less'

const SuperMap = () => {
const superMapRef = useRef(null)
const tiledLayerRef = useRef(null)
const markerClusterRef = useRef(null)

const iconList = [
{
locationX: 121.44,
locationY: 31.25,
},
{
locationX: 121.54,
locationY: 31.14,
},
{
locationX: 121.473919,
locationY: 30.955082,
},
{
locationX: 121.447153,
locationY: 30.800443,
},
]

useEffect(() => {
initSuperMap()
}, [])

useEffect(() => {
getResultLayer(iconList)
}, [])
const initSuperMap = () => {
const url = 'https://iserver.supermap.io/iserver/services/map-china400/rest/maps/China_4326'

const map = L.map('superMap', {
preferCanvas: true,
crs: L.CRS.EPSG4326,
center: [30.92, 121.56],
maxZoom: 18,
minZoom: 3,
zoom: 3,
attributionControl: false,
zoomControl: true,
})
const layer = new TiledMapLayer(url)
layer.addTo(map)
superMapRef.current = map
tiledLayerRef.current = layer

// map.on('click', function (e) {
// console.log('e', e);
// });
}

const getResultLayer = (projectList) => {
if (markerClusterRef.current) {
superMapRef?.current?.removeLayer(markerClusterRef.current)
}

const markerCluster = L.markerClusterGroup({
spiderfyOnMaxZoom: true,
showCoverageOnHover: false,
zoomToBoundsOnClick: true,
})

markerClusterRef.current = markerCluster

projectList.forEach((element) => {
const lat = element.locationY
const lon = element.locationX

const iconUrl = markerIcon

const myIcon = L.icon({
iconUrl,
iconSize: [20, 24],
})

const marker = L.marker([lat, lon], {
icon: myIcon,
})

markerCluster.addLayer(marker)
})

superMapRef?.current?.addLayer(markerCluster)
}

return (
<section className={styles.homeBox}>
<div id="superMap" className={styles.superMap} ref={superMapRef}></div>
</section>
)
}

export default SuperMap
4 changes: 4 additions & 0 deletions src/pages/superMap/index.module.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.superMap{
width: 1200px;
height: 600px;
}
9 changes: 9 additions & 0 deletions src/routers/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const PrismRender = lazy(() => import('@pages/prism'))
// const DynamicModal = lazy(() => import('@pages/dynamicModal'))
const BigScreen = lazy(() => import('@pages/bigScreen'))
const ReactAmap = lazy(() => import('@pages/reactAmap'))
const SuperMap = lazy(() => import('@pages/superMap'))
const PostMessage = lazy(() => import('@pages/postmessage'))
const GeoChart = lazy(() => import('@pages/geoChart'))
const MyIframe = lazy(() => import('@pages/postmessage/myIframe'))
Expand Down Expand Up @@ -205,6 +206,14 @@ const rootRouter = [
auth: false,
element: lazyLoad(MyIframe),
},
{
index: false,
path: 'super-map',
name: 'super-map',
key: '/super-map',
auth: false,
element: lazyLoad(SuperMap),
},
{
index: false,
path: 'coupons',
Expand Down

0 comments on commit 150aa2c

Please sign in to comment.