Skip to content

Commit 3d989c1

Browse files
authored
Merge pull request #468 from WatWowMap/fix-device-paths
Fix Device Paths
2 parents 89c6332 + 6eb186f commit 3d989c1

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "reactmap",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "React based frontend map.",
55
"main": "ReactMap.mjs",
66
"author": "TurtIeSocks <[email protected]>",

server/src/graphql/scannerTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = gql`
1010
type: String
1111
isMad: Boolean
1212
route: JSON
13+
radius: Int
1314
}
1415
1516
type Gym {

server/src/models/Device.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ module.exports = class Device extends Model {
3636
'instance_name',
3737
raw('json_extract(data, "$.area")')
3838
.as('route'),
39+
raw('json_extract(data, "$.radius")')
40+
.as('radius'),
3941
)
4042
}
4143
if (areaRestrictions.length) {

src/components/popups/DevicePoly.jsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
11
/* eslint-disable react/no-array-index-key */
22
import React, { memo } from 'react'
3-
import { Polyline, Polygon } from 'react-leaflet'
3+
import { Polyline, Polygon, Circle } from 'react-leaflet'
44

55
const DevicePoly = ({ device, color }) => {
6+
if (!device.route) return null
7+
68
if (typeof device.route === 'string') {
79
device.route = JSON.parse(device.route)
810
}
11+
if (device.type === 'leveling') {
12+
return (
13+
<>
14+
<Circle
15+
center={device.route}
16+
pathOptions={{ color }}
17+
/>
18+
<Circle
19+
center={device.route}
20+
radius={device.radius}
21+
pathOptions={{ color }}
22+
/>
23+
</>
24+
)
25+
}
926
const arrayRoute = device.route[0].lat ? [device.route] : device.route
1027
if (Array.isArray(arrayRoute)) {
11-
return device.type === 'circle_pokemon'
28+
return device?.type?.includes('circle')
1229
? arrayRoute.map((polygon, i) => (
1330
<Polyline
1431
key={i}

src/services/queries/device.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const getAllDevices = gql`
1111
route
1212
type
1313
isMad
14+
radius
1415
}
1516
}
1617
`

0 commit comments

Comments
 (0)