-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: quantile scale mutlipoygon 不准确 fix: #2086
- Loading branch information
Showing
3 changed files
with
89 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// | ||
|
||
// @ts-ignore | ||
import { Scene, PolygonLayer, LineLayer, Popup } from '@antv/l7'; | ||
// @ts-ignore | ||
import { GaodeMap, Map,Mapbox, GaodeMapV1 } from '@antv/l7-maps'; | ||
import React, { useEffect } from 'react'; | ||
|
||
export default () => { | ||
useEffect(() => { | ||
|
||
const scene = new Scene({ | ||
id: 'map', | ||
map: new GaodeMap({ | ||
style: 'light', | ||
center: [ -96, 37.8 ], | ||
zoom: 3 | ||
}) | ||
}); | ||
scene.on('loaded', () => { | ||
fetch( | ||
'https://gw.alipayobjects.com/os/basement_prod/d36ad90e-3902-4742-b8a2-d93f7e5dafa2.json' | ||
) | ||
.then(res => res.json()) | ||
.then(data => { | ||
const color = ['red', 'blue']; | ||
const layer = new PolygonLayer({}) | ||
.source(data) | ||
.scale('density', { | ||
type: 'quantile' | ||
}) | ||
.color( | ||
'density', color | ||
) | ||
.shape('fill') | ||
.active(true); | ||
const layer2 = new LineLayer({ | ||
zIndex: 2 | ||
}) | ||
.source(data) | ||
.color('#fff') | ||
.active(true) | ||
.size(1) | ||
.style({ | ||
lineType: 'dash', | ||
dashArray: [ 2, 2 ], | ||
}); | ||
scene.addLayer(layer); | ||
scene.addLayer(layer2); | ||
|
||
layer.on('mousemove', e => { | ||
const popup = new Popup({ | ||
offsets: [ 0, 0 ], | ||
closeButton: false | ||
}) | ||
.setLnglat(e.lngLat) | ||
.setHTML(`<span>${e.feature.properties.name}: ${e.feature.properties.density}</span>`); | ||
scene.addPopup(popup); | ||
}); | ||
}); | ||
}); | ||
|
||
|
||
}, []); | ||
return ( | ||
<div | ||
id="map" | ||
style={{ | ||
height: '500px', | ||
position: 'relative', | ||
}} | ||
/> | ||
); | ||
}; |
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,2 @@ | ||
### polygon Quantile | ||
<code src="./demos/quantile.tsx"></code> |
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