-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into demo/custom-ui
- Loading branch information
Showing
13 changed files
with
175 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { useScene } from '@antv/larkmap'; | ||
import { useEffect } from 'react'; | ||
import type { Map } from '../../types/map'; | ||
import { fitBounds, setMapStatus, setMapView } from '../../utils/map'; | ||
|
||
// 更新地图视野 | ||
export default (props: Map) => { | ||
const scene = useScene(); | ||
useEffect(() => { | ||
setMapView(props, scene); | ||
}, []); | ||
useEffect(() => { | ||
setMapStatus(props, scene); | ||
}, [props.enableRotate, props.enableScroll, props.enableZoom]); | ||
useEffect(() => { | ||
fitBounds(props, scene); | ||
}, [props.includePoints, props.markers, props.polyline, props.includePadding]); | ||
|
||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { ILayer } from '@antv/l7'; | ||
import { useScene } from '@antv/larkmap'; | ||
import { useEffect, useState } from 'react'; | ||
import type { Map } from '../../types/map'; | ||
import { setMapContext, setMarkers } from '../../utils/map'; | ||
// 渲染标记点 | ||
export default (props: Map) => { | ||
const scene = useScene(); | ||
const [layers, setLayers] = useState<ILayer[]>([]); | ||
const removeLayers = () => { | ||
layers.forEach((item) => { | ||
scene.removeLayer(item); | ||
}); | ||
}; | ||
useEffect(() => { | ||
if (!props.markers) return; | ||
// 异步调用 | ||
setMapContext(props, scene)?.then(() => { | ||
// 初始化资源 | ||
const markerLayer = setMarkers(props.markers || []); | ||
removeLayers(); | ||
markerLayer.forEach((item) => { | ||
scene.addLayer(item); | ||
}); | ||
setLayers(markerLayer); | ||
}); | ||
return () => { | ||
removeLayers(); | ||
}; | ||
}, [props.markers]); | ||
|
||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { ILayer } from '@antv/l7'; | ||
import { useScene } from '@antv/larkmap'; | ||
import { useEffect, useState } from 'react'; | ||
import type { Map } from '../../types/map'; | ||
import { setPolyline } from '../../utils/map'; | ||
// 渲染线图层 | ||
export default (props: Map) => { | ||
const scene = useScene(); | ||
const [layers, setLayers] = useState<ILayer[]>([]); | ||
const removeLayers = () => { | ||
layers.forEach((item) => { | ||
scene.removeLayer(item); | ||
}); | ||
}; | ||
useEffect(() => { | ||
if (!props.polyline) return; | ||
const lineLayers = setPolyline(props.polyline || []); | ||
removeLayers(); | ||
lineLayers.forEach((item) => { | ||
scene.addLayer(item); | ||
}); | ||
setLayers(lineLayers); | ||
|
||
return () => { | ||
removeLayers(); | ||
}; | ||
}, [props.polyline]); | ||
|
||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import MapView from './MapView'; | ||
import Marker from './Marker'; | ||
import Polyline from './Polyline'; | ||
|
||
export { MapView, Marker, Polyline }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.