Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nos Hs2023
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Språksamlingane
stadnamn
Nos Hs2023
Commits
f61397b0
Commit
f61397b0
authored
6 years ago
by
esikkala
Browse files
Options
Downloads
Patches
Plain Diff
Add colors for markers and grey marker clusters
parent
956fde53
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/client/components/LeafletMap.js
+65
-25
65 additions, 25 deletions
src/client/components/LeafletMap.js
src/client/index.html
+6
-0
6 additions, 0 deletions
src/client/index.html
with
71 additions
and
25 deletions
src/client/components/LeafletMap.js
+
65
−
25
View file @
f61397b0
...
@@ -28,6 +28,12 @@ import 'Leaflet.extra-markers/dist/css/leaflet.extra-markers.min.css';
...
@@ -28,6 +28,12 @@ import 'Leaflet.extra-markers/dist/css/leaflet.extra-markers.min.css';
import
'
Leaflet.extra-markers/dist/img/markers_default.png
'
;
import
'
Leaflet.extra-markers/dist/img/markers_default.png
'
;
import
'
Leaflet.extra-markers/dist/img/markers_shadow.png
'
;
import
'
Leaflet.extra-markers/dist/img/markers_shadow.png
'
;
import
markerShadowIcon
from
'
../img/markers/marker-shadow.png
'
;
import
markerIconViolet
from
'
../img/markers/marker-icon-violet.png
'
;
import
markerIconGreen
from
'
../img/markers/marker-icon-green.png
'
;
import
markerIconRed
from
'
../img/markers/marker-icon-red.png
'
;
import
markerIconOrange
from
'
../img/markers/marker-icon-orange.png
'
;
const
MAPBOX_ACCESS_TOKEN
=
'
pk.eyJ1IjoiZWtrb25lbiIsImEiOiJjam5vampzZ28xd2dyM3BzNXR0Zzg4azl4In0.eozyF-bBaZbA3ibhvJlJpQ
'
;
const
MAPBOX_ACCESS_TOKEN
=
'
pk.eyJ1IjoiZWtrb25lbiIsImEiOiJjam5vampzZ28xd2dyM3BzNXR0Zzg4azl4In0.eozyF-bBaZbA3ibhvJlJpQ
'
;
const
style
=
{
const
style
=
{
...
@@ -50,16 +56,16 @@ const styles = () => ({
...
@@ -50,16 +56,16 @@ const styles = () => ({
},
},
});
});
//
https://github.com/pointhi/leaflet-color-markers
//https://github.com/pointhi/leaflet-color-markers
//
const ColorIcon = L.Icon.extend({
const
ColorIcon
=
L
.
Icon
.
extend
({
//
options: {
options
:
{
//
shadowUrl:
'img/
marker
s/marker-shadow.png'
,
shadowUrl
:
marker
ShadowIcon
,
//
iconSize: [25, 41],
iconSize
:
[
25
,
41
],
//
iconAnchor: [12, 41],
iconAnchor
:
[
12
,
41
],
//
popupAnchor: [1, -34],
popupAnchor
:
[
1
,
-
34
],
//
shadowSize: [41, 41]
shadowSize
:
[
41
,
41
]
//
}
}
//
});
});
class
LeafletMap
extends
React
.
Component
{
class
LeafletMap
extends
React
.
Component
{
...
@@ -204,7 +210,12 @@ class LeafletMap extends React.Component {
...
@@ -204,7 +210,12 @@ class LeafletMap extends React.Component {
}
}
});
});
}
else
{
}
else
{
clusterer
=
new
L
.
MarkerClusterGroup
();
clusterer
=
new
L
.
MarkerClusterGroup
({
iconCreateFunction
:
cluster
=>
{
const
childCount
=
cluster
.
getChildCount
();
return
new
L
.
DivIcon
({
html
:
'
<div><span>
'
+
childCount
+
'
</span></div>
'
,
className
:
'
marker-cluster marker-cluster-grey
'
,
iconSize
:
new
L
.
Point
(
40
,
40
)
});
}
});
}
}
results
.
forEach
(
value
=>
{
results
.
forEach
(
value
=>
{
...
@@ -224,21 +235,50 @@ class LeafletMap extends React.Component {
...
@@ -224,21 +235,50 @@ class LeafletMap extends React.Component {
}
else
{
}
else
{
const
{
lat
,
long
}
=
result
;
const
{
lat
,
long
}
=
result
;
const
latLng
=
[
+
lat
,
+
long
];
const
latLng
=
[
+
lat
,
+
long
];
// https://github.com/coryasilva/Leaflet.ExtraMarkers
let
marker
=
null
;
const
icon
=
L
.
ExtraMarkers
.
icon
({
icon
:
'
fa-number
'
,
if
(
this
.
props
.
variant
===
'
productionPlaces
'
)
{
number
:
result
.
manuscriptCount
,
// https://github.com/coryasilva/Leaflet.ExtraMarkers
markerColor
:
'
red
'
,
const
icon
=
L
.
ExtraMarkers
.
icon
({
shape
:
'
circle
'
,
icon
:
'
fa-number
'
,
prefix
:
'
fa
'
number
:
result
.
manuscriptCount
,
});
markerColor
:
'
red
'
,
shape
:
'
circle
'
,
prefix
:
'
fa
'
});
marker
=
L
.
marker
(
latLng
,
{
icon
:
icon
,
manuscriptCount
:
result
.
manuscriptCount
?
result
.
manuscriptCount
:
null
,
id
:
result
.
id
})
.
on
(
'
click
'
,
this
.
markerOnClick
);
}
else
{
const
color
=
'
green
'
;
let
markerIcon
=
''
;
switch
(
color
)
{
case
'
violet
'
:
markerIcon
=
markerIconViolet
;
break
;
case
'
green
'
:
markerIcon
=
markerIconGreen
;
break
;
case
'
red
'
:
markerIcon
=
markerIconRed
;
break
;
case
'
orange
'
:
markerIcon
=
markerIconOrange
;
break
;
}
marker
=
L
.
marker
(
latLng
,
{
icon
:
new
ColorIcon
({
iconUrl
:
markerIcon
}),
id
:
result
.
id
})
.
on
(
'
click
'
,
this
.
markerOnClick
);
}
const
marker
=
L
.
marker
(
latLng
,
{
icon
:
icon
,
manuscriptCount
:
result
.
manuscriptCount
?
result
.
manuscriptCount
:
null
,
id
:
result
.
id
})
.
on
(
'
click
'
,
this
.
markerOnClick
);
return
marker
;
return
marker
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/client/index.html
+
6
−
0
View file @
f61397b0
...
@@ -29,6 +29,12 @@
...
@@ -29,6 +29,12 @@
font-size
:
14px
;
font-size
:
14px
;
font-family
:
'Roboto'
,
sans-serif
;
font-family
:
'Roboto'
,
sans-serif
;
}
}
.marker-cluster-grey
{
background-color
:
rgba
(
128
,
128
,
128
,
0.6
);
}
.marker-cluster-small
div
{
background-color
:
rgba
(
211
,
211
,
211
,
0.6
);
}
.rstcustom__rowWrapper
{
.rstcustom__rowWrapper
{
display
:
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment