Commit 63a602b0 authored by 田翔's avatar 田翔

fix: 加载地图尝试修复

parent 86030319
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "4.7.9", "version": "4.8.0",
"description": "4.7.9 增加手写签名控件", "description": "4.8.0 加载地图尝试修复报错问题",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -64,6 +64,39 @@ const Coordinate = (props) => { ...@@ -64,6 +64,39 @@ const Coordinate = (props) => {
} }
} }
} }
const getMapInfo = (viewObject) => {
if (viewObject) {
setView(viewObject);
let coordGetLayer = viewObject.map.layers.find(layer => layer.id == 'coordGet');
if (coordGetLayer) {
viewObject.map.remove(coordGetLayer);
} else {
coordGetLayer = new GraphicsLayer({
id: 'coordGet',
});
}
viewObject.map.add(coordGetLayer);
if (value) {
coordGetLayer.removeAll();
const newVal = value.split(',');
const defalutGraphic = createGraphic(new Point({
x: newVal[0],
y: newVal[1],
spatialReference: {
wkid: 3857
}
}));
coordGetLayer.add(defalutGraphic);
setTimeout(() => {
viewObject.goTo({
center: geomUtils.toGeometry({ x: Number(newVal[0]), y: Number(newVal[1]) }),
scale: viewObject.scale - 1,
})
}, 2000)
}
}
}
const createGraphic = (geometry) => { const createGraphic = (geometry) => {
return new Graphic({ return new Graphic({
...@@ -167,7 +200,7 @@ const Coordinate = (props) => { ...@@ -167,7 +200,7 @@ const Coordinate = (props) => {
return ( return (
<div style={{ width: '100%', height: '150px' }}> <div style={{ width: '100%', height: '150px' }}>
<ArcGISSceneMap <ArcGISSceneMap
getMapInfo={getView} getMapInfo={getMapInfo}
widgets={[]} widgets={[]}
token={token} token={token}
client={token ? client : 'sandbox'} client={token ? client : 'sandbox'}
......
...@@ -25,8 +25,7 @@ const Device = (props) => { ...@@ -25,8 +25,7 @@ const Device = (props) => {
let clickref = useRef(null) let clickref = useRef(null)
let view = useRef(null) let view = useRef(null)
const getMapInfo = (mapObj, Map, disabled) => { const getView = (mapObj, Map) => {
console.log('disabled', disabled)
setTimeout(() => { setTimeout(() => {
if (mapObj) { if (mapObj) {
view.current = mapObj view.current = mapObj
...@@ -81,6 +80,61 @@ const Device = (props) => { ...@@ -81,6 +80,61 @@ const Device = (props) => {
}, 500) }, 500)
} }
const getMapInfo = (mapObj, Map) => {
setTimeout(() => {
if (mapObj) {
view.current = mapObj
let arr = (value && value.split(',')) || []
let obj = (arr.length === 2) ? { point: { x: Number(arr[0]), y: Number(arr[1]) } } : {}
if (arr.length === 2) {
view.current.goTo({
center: geomUtils.toGeometry({ x: Number(arr[0]), y: Number(arr[1]) }),
zoom: 15
})
}
clickref.current = new ClickQuery({
view: view.current,
offsetX: -150,
offsetY: -310,
continuous: true,
onlyWhatch: true,
...obj,
callback: ({ clickPoint, matchPoint, data }) => {
gisInfo = {}
if (layer) {
view.current.map.remove(layer)
}
if (matchPoint) {
geometrystr = `${matchPoint.x},${matchPoint.y}`
gisInfo = { layerName: data.layerName, gisCode: data.attributes.code }
} else if (clickPoint) {
geometrystr = `${clickPoint.x},${clickPoint.y}`
layer = new GraphicsLayer({
id: 'ok-layers',
})
if (geometrystr) {
const polypointGraphic = new Graphic({
geometry: geomUtils.toGeometry({
x: Number(geometrystr.split(',')[0]),
y: Number(geometrystr.split(',')[1])
}),
symbol: {
type: "picture-marker",
url: point,
width: "20px",
height: "20px"
},
})
layer.add(polypointGraphic)
view.current.map.add(layer)
}
}
}
})
}
}, 500)
}
const iconClick = () => { const iconClick = () => {
if (addons) { if (addons) {
setVisible(true) setVisible(true)
...@@ -127,7 +181,7 @@ const Device = (props) => { ...@@ -127,7 +181,7 @@ const Device = (props) => {
return ( return (
<div style={{ width: '100%', height: '120px' }}> <div style={{ width: '100%', height: '120px' }}>
<ArcGISSceneMap <ArcGISSceneMap
getMapInfo={(mapObj, Map) => getMapInfo(mapObj, Map, true)} getMapInfo={getMapInfo}
widgets={[]} widgets={[]}
token={token} token={token}
client={token ? client : 'sandbox'} client={token ? client : 'sandbox'}
...@@ -172,7 +226,7 @@ const Device = (props) => { ...@@ -172,7 +226,7 @@ const Device = (props) => {
{...disabled ? { footer: null } : {}} {...disabled ? { footer: null } : {}}
> >
<ArcGISSceneMap <ArcGISSceneMap
getMapInfo={(mapObj, Map) => getMapInfo(mapObj, Map, disabled)} getMapInfo={getView}
widgets={[]} widgets={[]}
token={token} token={token}
client={token ? client : 'sandbox'} client={token ? client : 'sandbox'}
......
...@@ -49,6 +49,12 @@ const DrawArea = (props) => { ...@@ -49,6 +49,12 @@ const DrawArea = (props) => {
createPaths(viewObject) createPaths(viewObject)
} }
const getMapInfo = (viewObject) => {
setRings(isJson(value) ? JSON.parse(value) : '')
viewRef.current = viewObject
createPaths(viewObject)
}
const getPoints = (view) => { const getPoints = (view) => {
if (view) { if (view) {
view.map.remove(layers.current) view.map.remove(layers.current)
...@@ -103,7 +109,7 @@ const DrawArea = (props) => { ...@@ -103,7 +109,7 @@ const DrawArea = (props) => {
return ( return (
<div style={{ width: '100%', height: '150px' }}> <div style={{ width: '100%', height: '150px' }}>
<ArcGISSceneMap <ArcGISSceneMap
getMapInfo={getView} getMapInfo={getMapInfo}
widgets={[]} widgets={[]}
token={token} token={token}
client={token ? client : 'sandbox'} client={token ? client : 'sandbox'}
......
...@@ -48,6 +48,12 @@ const DrawPath = (props) => { ...@@ -48,6 +48,12 @@ const DrawPath = (props) => {
createPaths(viewObject) createPaths(viewObject)
} }
const getMapInfo = (viewObject) => {
setPaths(isJson(value) ? JSON.parse(value) : '')
viewRef.current = viewObject
createPaths(viewObject)
}
const getPoints = (view) => { const getPoints = (view) => {
if (view) { if (view) {
view.map.remove(layers.current) view.map.remove(layers.current)
...@@ -102,7 +108,7 @@ const DrawPath = (props) => { ...@@ -102,7 +108,7 @@ const DrawPath = (props) => {
return ( return (
<div style={{ width: '100%', height: '150px' }}> <div style={{ width: '100%', height: '150px' }}>
<ArcGISSceneMap <ArcGISSceneMap
getMapInfo={getView} getMapInfo={getMapInfo}
widgets={[]} widgets={[]}
token={token} token={token}
client={token ? client : 'sandbox'} client={token ? client : 'sandbox'}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment