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

Use TextBox in InfoLayersSample and remove platform specific code to show info #2222

Merged
merged 14 commits into from Oct 20, 2023

Conversation

pauldendulk
Copy link
Member

To show the data of a feature when using the Info event we had platform specific code. Not on all platforms, and with differences between platforms. This PR adds a TextBox in the InfoLayersSample so, that all the platform specific code could be removed.

I will test the changes platforms to check if I did not remove to much, or broke something otherwise.

The PR only affects the samples.

@pauldendulk pauldendulk changed the title WIP Use textbox in info sample WIP Use TextBox in InfoLayersSample and remove platform specific code to show info Oct 13, 2023
@pauldendulk
Copy link
Member Author

Info with Mapsui.Android on Windows Subsystem for Android:

image

@pauldendulk
Copy link
Member Author

pauldendulk commented Oct 14, 2023

I work on this because:

  • We released a stable version, I don't want to change to much in that version right, so do some things around the core.
  • By working on the samples I dog feed Mapsui and this way I have found 4 (minor) bugs last week.
  • I want to remove platform specific code and replace it with generic code to make the code easier to maintain.
  • By going through the samples it set my mind in motion thinking about a better design, important for the v5.

image

@pauldendulk pauldendulk changed the title WIP Use TextBox in InfoLayersSample and remove platform specific code to show info Use TextBox in InfoLayersSample and remove platform specific code to show info Oct 15, 2023
@pauldendulk
Copy link
Member Author

pauldendulk commented Oct 16, 2023

This PR removes the map info field in the platform specific UI and adds it to the InfoLayerSample, but there are other samples that use info as well. What to do with those? Below is a list of search for IsInfoLayer = true. I went through it, not all are important. Options:

  • I could add sample specific info for a few, but for debugging and testing it is handy to have for all. Especially for solutions where we use intermediates, like TiledRasterizingLayer.
  • An alternative I am now thinking about is to add a default feature info textbox on the shared MapControl, which could be turned on and off with a boolean. For users this would be useful too during development. But when you start with that it becomes logical to think about other widgets as well, like the zoomInOutButtons, and there are too many choices to make in that regard, which I don't want to make for v4.
  • Perhaps a better option would be to add a MapInfoTextBox which should be added explicitly but has more off the shelf functionality, so it becomes easy to add.

image

@pauldendulk
Copy link
Member Author

After a bit of thinking I prefer the last option the most. User would have to explicitly add it, but the ShowMapInfoInMap option would probably be off by default, so it would also need:
map.ShowMapInfoInMap = true'
Instead of:
map.Widgest.Add(new MapInfoWidget());
This is not a real advantage so, I prefer to keep the MapControl empty by default. And as mentioned elsewhere, we could provide a builder for some common off the shelf configurations.

@pauldendulk
Copy link
Member Author

About building the MapInfoWidget. It would need to react to events all over the map so would have to be a transparent map sized widget, with the TextBox as a widget within the widget.

Copy link
Contributor

@inforithmics inforithmics left a comment

Choose a reason for hiding this comment

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

Nice improvement on maintainability

@@ -33,6 +35,18 @@ public static Map CreateMap()
map.Layers.Add(new WritableLayer());
map.Layers.Add(CreateLineLayer());

var textBox = CreateTextBox();
map.Widgets.Add(textBox);
Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea to centralize the display of the mapinfo reduces the platform specific sample code and tests mapsui widgets.

textBox.Text = "";
else
textBox.Text = $"Feature Info - {a.MapInfo.Feature.ToDisplayText()}";
map.RefreshGraphics();
Copy link
Contributor

Choose a reason for hiding this comment

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

With this pull request changes on the widgets trigger automatically a redraw

#2183

@inforithmics
Copy link
Contributor

inforithmics commented Oct 18, 2023

I too would keep the MapControl slim. But I think there is a need for something like MapView where there is a default projection set and utility layers and widgets per default instantiated. Could have a different name than mapview.

So on MapView there could be a showmapinfo property and on mapcontrol you add the mapinfowidget.

@pauldendulk
Copy link
Member Author

But I think there is a need for something like MapView where there is a default projection set and utility layers and widgets per default instantiated. Could have a different name than mapview.

The alternative I am thinking about would be a builder in which you could create such a component with one line of code. There could be different builders for different configurations. I am not sure yet if that would be sufficient replacement.

@pauldendulk
Copy link
Member Author

I also added a MapInfoWidget (and MapInfoWidgetRenderer), so this MR does not only changes the samples. I added it to the samples where I though it would be useful.

map.Widgets.Add(new MapInfoWidget(map));

@pauldendulk pauldendulk merged commit 492fac0 into master Oct 20, 2023
6 checks passed
@pauldendulk pauldendulk deleted the feature/use-textbox-in-info-sample branch October 20, 2023 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants