arcgis js 4 与d3.js 构建可视化(基础)
这次我们用d3.js 来构建可视化
首先我们 定义一些坐标转换的工具方法
toScreen 方法
```javascript
//构建arcgis 的mapView
let view = mapView
toScreen(coordinate) {
-
let coordinateType = getXYType(coordinate[0],coordinate[1]);
-
let coordXY = getRealXY(coordinate[0],coordinate[1],coordinateType);
-
-
let item = {
-
x: coordXY.x,
-
y: coordXY.y,
-
spatialReference: view.spatialReference
-
};
-
let screenPoint = view.toScreen(item);
-
return screenPoint;
};
getRealXY (x,y,xyType){
if(view.spatialReference.wkid === 4326 || view.spatialReference.wkid === 4490){
if(xyType == 'WGS84') {
return {
x: x,
y: y
}
} else {
return getLngLat(x,y);
}
} else if(view.spatialReference.wkid === 102100){
if(xyType == 'Mercator') {
return {
x: x,
y: y
}
} else {
return getMercator(x,y);
}
}
return {
x: x,
y: y
}
}
getXYType(x,y){
if(x <= 180 && y <= 90){
return "WGS84"
}else{
return "Mercator"
}
}
更多参考 https://xiaozhuanlan.com/topic/1062845973