Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rex Dri
Rex Dri
Commits
820a7491
Unverified
Commit
820a7491
authored
Apr 25, 2020
by
Gautier D
Committed by
Florent Chehab
May 03, 2020
Browse files
refacto(backend): modify main map
parent
a3ad5631
Changes
2
Hide whitespace changes
Inline
Side-by-side
frontend/src/components/map/BaseMap.jsx
View file @
820a7491
...
...
@@ -49,7 +49,8 @@ const ALL_MAPS = {};
*
* If an id is provided, the state of the map will be automatically saved and regenerated.
*/
function
BaseMap
({
id
,
campuses
})
{
function
BaseMap
({
id
,
universities
})
{
console
.
log
(
"
iciciciiojoij
"
,
universities
);
const
theme
=
useTheme
();
const
classes
=
useStyles
();
...
...
@@ -68,7 +69,7 @@ function BaseMap({ id, campuses }) {
[
id
,
ALL_MAPS
]
);
const
openPopup
=
useCallback
(
campus
Info
=>
setPopup
(
campus
Info
),
[]);
const
openPopup
=
useCallback
(
university
Info
=>
setPopup
(
university
Info
),
[]);
const
closePopup
=
useCallback
(()
=>
setPopup
(
undefined
),
[]);
const
toggleHover
=
useCallback
((
mapInstance
,
cursor
)
=>
{
...
...
@@ -81,21 +82,24 @@ function BaseMap({ id, campuses }) {
return
(
<
Layer
type
=
"circle"
id
=
{
`
campus
es
${
selected
?
"
selected
"
:
"
notSelected
"
}
`
}
id
=
{
`
universiti
es
${
selected
?
"
selected
"
:
"
notSelected
"
}
`
}
paint
=
{
{
"
circle-color
"
:
getLegendColorOpacity
(
theme
,
selected
).
color
,
"
circle-opacity
"
:
getLegendColorOpacity
(
theme
,
selected
).
opacity
,
"
circle-radius
"
:
8
}
}
>
{
campus
es
{
universiti
es
.
filter
(
c
=>
c
.
selected
===
selected
)
.
map
((
campus
Info
,
idx
)
=>
(
.
map
((
university
Info
,
idx
)
=>
(
<
Feature
// eslint-disable-next-line react/no-array-index-key
key
=
{
idx
}
coordinates
=
{
[
campusInfo
.
lon
,
campusInfo
.
lat
]
}
onClick
=
{
()
=>
openPopup
(
campusInfo
)
}
coordinates
=
{
[
universityInfo
.
main_campus_lon
,
universityInfo
.
main_campus_lat
]
}
onClick
=
{
()
=>
openPopup
(
universityInfo
)
}
onMouseEnter
=
{
({
map
})
=>
toggleHover
(
map
,
"
pointer
"
)
}
onMouseLeave
=
{
({
map
})
=>
toggleHover
(
map
,
""
)
}
/>
...
...
@@ -103,7 +107,7 @@ function BaseMap({ id, campuses }) {
</
Layer
>
);
},
[
campus
es
,
theme
]
[
universiti
es
,
theme
]
);
const
style
=
theme
.
palette
.
type
===
"
light
"
?
"
light
"
:
"
dark
"
;
...
...
@@ -118,6 +122,7 @@ function BaseMap({ id, campuses }) {
}
return
(
<
div
style
=
{
{
position
:
"
relative
"
}
}
>
<
Map
style
=
{
`/map-server/styles/
${
style
}
/style.json`
}
...
...
@@ -126,14 +131,14 @@ function BaseMap({ id, campuses }) {
center
=
{
mapStatus
.
center
}
onMoveEnd
=
{
saveStatus
}
>
{
campus
es
&&
(
{
universiti
es
&&
(
<>
{
renderLayer
(
true
)
}
{
renderLayer
(
false
)
}
</>
)
}
{
popup
&&
(
<
Popup
key
=
{
popup
.
univId
}
coordinates
=
{
[
popup
.
lon
,
popup
.
lat
]
}
>
<
Popup
key
=
{
popup
.
univId
}
coordinates
=
{
[
popup
.
main_campus_lon
,
popup
.
main_campus_
lat
]
}
>
<
UnivMapPopup
{
...
popup
}
handleClose
=
{
closePopup
}
/>
</
Popup
>
)
}
...
...
@@ -147,12 +152,12 @@ function BaseMap({ id, campuses }) {
BaseMap
.
propTypes
=
{
id
:
PropTypes
.
string
,
campus
es
:
PropTypes
.
array
universiti
es
:
PropTypes
.
array
};
BaseMap
.
defaultProps
=
{
id
:
undefined
,
campus
es
:
undefined
universiti
es
:
undefined
};
export
default
BaseMap
;
frontend/src/components/map/MainMap.jsx
View file @
820a7491
...
...
@@ -28,8 +28,8 @@ function MainMap() {
univLogoUrl
:
univ
.
logo
,
cityName
:
univ
.
city
,
countryName
:
univ
.
country
,
lat
:
parseFloat
(
univ
.
main_campus_lat
),
lon
:
parseFloat
(
univ
.
main_campus_lon
),
main_campus_
lat
:
parseFloat
(
univ
.
main_campus_lat
),
main_campus_
lon
:
parseFloat
(
univ
.
main_campus_lon
),
univId
:
univ
.
id
,
selected
:
listUnivSel
===
null
||
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment