@@ -38,6 +38,7 @@ public class MarkerSet {
3838
3939 private String label ;
4040 private boolean toggleable , defaultHidden ;
41+ private int sorting ;
4142 private final ConcurrentHashMap <String , Marker > markers ;
4243
4344 /**
@@ -56,10 +57,7 @@ private MarkerSet() {
5657 * @see #setLabel(String)
5758 */
5859 public MarkerSet (String label ) {
59- this .label = Objects .requireNonNull (label );
60- this .toggleable = true ;
61- this .defaultHidden = false ;
62- this .markers = new ConcurrentHashMap <>();
60+ this (label , true , false );
6361 }
6462
6563 /**
@@ -77,6 +75,7 @@ public MarkerSet(String label, boolean toggleable, boolean defaultHidden) {
7775 this .label = Objects .requireNonNull (label );
7876 this .toggleable = toggleable ;
7977 this .defaultHidden = defaultHidden ;
78+ this .sorting = 0 ;
8079 this .markers = new ConcurrentHashMap <>();
8180 }
8281
@@ -149,6 +148,28 @@ public void setDefaultHidden(boolean defaultHidden) {
149148 this .defaultHidden = defaultHidden ;
150149 }
151150
151+ /**
152+ * Returns the sorting-value that will be used by the webapp to sort the marker-sets.<br>
153+ * A lower value makes the marker-set sorted first (in lists and menus), a higher value makes it sorted later.<br>
154+ * If multiple marker-sets have the same sorting-value, their order will be arbitrary.<br>
155+ * This value defaults to 0.
156+ * @return This marker-sets sorting-value
157+ */
158+ public int getSorting () {
159+ return sorting ;
160+ }
161+
162+ /**
163+ * Sets the sorting-value that will be used by the webapp to sort the marker-sets ("default"-sorting).<br>
164+ * A lower value makes the marker-set sorted first (in lists and menus), a higher value makes it sorted later.<br>
165+ * If multiple marker-sets have the same sorting-value, their order will be arbitrary.<br>
166+ * This value defaults to 0.
167+ * @param sorting the new sorting-value for this marker-set
168+ */
169+ public void setSorting (int sorting ) {
170+ this .sorting = sorting ;
171+ }
172+
152173 /**
153174 * Getter for a (modifiable) {@link Map} of all {@link Marker}s in this {@link MarkerSet}.
154175 * The keys of the map are the id's of the {@link Marker}s.
@@ -220,6 +241,7 @@ public static class Builder {
220241
221242 private String label ;
222243 private Boolean toggleable , defaultHidden ;
244+ Integer sorting ;
223245
224246 /**
225247 * Sets the label of the {@link MarkerSet}.
@@ -262,6 +284,18 @@ public Builder defaultHidden(Boolean defaultHidden) {
262284 return this ;
263285 }
264286
287+ /**
288+ * Sets the sorting-value that will be used by the webapp to sort the marker-sets ("default"-sorting).<br>
289+ * A lower value makes the marker-set sorted first (in lists and menus), a higher value makes it sorted later.<br>
290+ * If multiple marker-sets have the same sorting-value, their order will be arbitrary.<br>
291+ * This value defaults to 0.
292+ * @param sorting the new sorting-value for this marker-set
293+ */
294+ public Builder sorting (Integer sorting ) {
295+ this .sorting = sorting ;
296+ return this ;
297+ }
298+
265299 /**
266300 * Creates a new {@link MarkerSet} with the current builder-settings.<br>
267301 * The minimum required settings to build this marker-set are:
@@ -276,6 +310,7 @@ public MarkerSet build() {
276310 );
277311 if (toggleable != null ) markerSet .setToggleable (toggleable );
278312 if (defaultHidden != null ) markerSet .setDefaultHidden (defaultHidden );
313+ if (sorting != null ) markerSet .setSorting (sorting );
279314 return markerSet ;
280315 }
281316
0 commit comments