Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add allow-overlap for symbols #507

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ static PropertyValue[] interpretSymbolLayerProperties(Object o) {
case "icon-rotation-alignment":
properties.add(PropertyFactory.iconRotationAlignment(expression));
break;
case "icon-allow-ovelap":
properties.add(PropertyFactory.iconAllowOverlap(expression));
case "icon-size":
properties.add(PropertyFactory.iconSize(expression));
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ class LayerPropertyConverter {
for (propertyName, propertyValue) in properties {
let expression = interpretExpression(propertyName: propertyName, expression: propertyValue)
switch propertyName {
case "icon-allow-overlap":
symbolLayer.iconAllowsOverlap = expression
case "icon-ignore-placement":
symbolLayer.iconIgnoresPlacement = expression
case "icon-optional":
symbolLayer.iconOptional = expression
case "icon-opacity":
symbolLayer.iconOpacity = expression
case "icon-color":
Expand Down
4 changes: 3 additions & 1 deletion maplibre_gl/lib/src/layer_properties.dart
Original file line number Diff line number Diff line change
Expand Up @@ -931,11 +931,13 @@ class SymbolLayerProperties implements LayerProperties {
addIfPresent('symbol-avoid-edges', symbolAvoidEdges);
addIfPresent('symbol-sort-key', symbolSortKey);
addIfPresent('symbol-z-order', symbolZOrder);
addIfPresent('icon-allow-overlap', iconAllowOverlap);
addIfPresent('icon-ignore-placement', iconIgnorePlacement);
addIfPresent('icon-optional', iconOptional);
addIfPresent('icon-rotation-alignment', iconRotationAlignment);
addIfPresent('icon-size', iconSize);
addIfPresent('icon-allow-overlap', iconAllowOverlap);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like you needed to change this file — all properties were already there.

addIfPresent('icon-ignore-placement', iconIgnorePlacement);
addIfPresent('icon-optional', iconOptional);
addIfPresent('icon-text-fit', iconTextFit);
addIfPresent('icon-text-fit-padding', iconTextFitPadding);
addIfPresent('icon-image', iconImage);
Expand Down
1 change: 0 additions & 1 deletion maplibre_gl/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ dependencies:
sdk: flutter
maplibre_gl_platform_interface: ^0.20.0
maplibre_gl_web: ^0.20.0

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert.

dev_dependencies:
very_good_analysis: ^5.0.0

Expand Down
13 changes: 13 additions & 0 deletions maplibre_gl_platform_interface/lib/src/symbol.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class SymbolOptions {
/// By default, every non-specified field is null, meaning no desire to change
/// symbol defaults or current configuration.
const SymbolOptions({
this.iconAllowOverlap,
this.iconIgnorePlacement,
this.iconOptional,
this.iconSize,
this.iconImage,
this.iconRotate,
Expand Down Expand Up @@ -90,6 +93,9 @@ class SymbolOptions {
this.draggable,
});

final bool? iconAllowOverlap;
final bool? iconIgnorePlacement;
final bool? iconOptional;
final double? iconSize;
final String? iconImage;
final double? iconRotate;
Expand Down Expand Up @@ -125,6 +131,9 @@ class SymbolOptions {

SymbolOptions copyWith(SymbolOptions changes) {
return SymbolOptions(
iconOptional: changes.iconOptional ?? iconOptional,
iconIgnorePlacement: changes.iconIgnorePlacement ?? iconIgnorePlacement,
iconAllowOverlap: changes.iconAllowOverlap ?? iconAllowOverlap,
iconSize: changes.iconSize ?? iconSize,
iconImage: changes.iconImage ?? iconImage,
iconRotate: changes.iconRotate ?? iconRotate,
Expand Down Expand Up @@ -165,6 +174,10 @@ class SymbolOptions {
}
}

addIfPresent('iconOptional', iconOptional);
addIfPresent('iconIgnorePlacement', iconIgnorePlacement);
addIfPresent('iconOptional', iconOptional);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate line.

addIfPresent('iconAllowOverlap', iconAllowOverlap);
addIfPresent('iconSize', iconSize);
addIfPresent('iconImage', iconImage);
addIfPresent('iconRotate', iconRotate);
Expand Down
9 changes: 9 additions & 0 deletions maplibre_gl_web/lib/src/convert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ class Convert {
if (options.iconSize != null) {
properties['iconSize'] = options.iconSize;
}
if (options.iconAllowOverlap != null) {
properties['iconAllowOverlap'] = options.iconAllowOverlap;
}
if (options.iconIgnorePlacement != null) {
properties['iconIgnorePlacement'] = options.iconIgnorePlacement;
}
if (options.iconOptional != null) {
properties['iconOptional'] = options.iconOptional;
}
if (options.iconImage != null) {
properties['iconImage'] = options.iconImage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ class SymbolLayoutJsImpl {
if (symbolLayout.iconSize != null) {
dict['icon-size'] = symbolLayout.iconSize;
}
if (symbolLayout.iconAllowOverlap != null) {
dict['icon-allow-overlap'] = symbolLayout.iconAllowOverlap;
}
if (symbolLayout.iconIgnorePlacement != null) {
dict['icon-ignore-placement'] = symbolLayout.iconIgnorePlacement;
}
if (symbolLayout.iconOptional != null) {
dict['icon-optional'] = symbolLayout.iconOptional;
}
if (symbolLayout.iconTextFit != null) {
dict['icon-text-fit'] = symbolLayout.iconTextFit;
}
Expand Down
4 changes: 2 additions & 2 deletions maplibre_gl_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ flutter:
web:
pluginClass: MapLibreMapPlugin
fileName: maplibre_gl_web.dart

dependencies:
flutter:
sdk: flutter
flutter_web_plugins:
sdk: flutter
image: ^4.0.17
js: ">=0.6.7 <0.8.0"
maplibre_gl_platform_interface: ^0.20.0
maplibre_gl_platform_interface:
path: ../maplibre_gl_platform_interface
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this file doesn't seem in scope for the PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project uses melos to orchestrate its packages.

dart pub global activate melos
melos bootstrap

This will resolve the dependencies so that no changes to pubspec.yaml are necessary.

meta: ^1.3.0

dev_dependencies:
Expand Down
Loading