onaio / kujaku

Mapping and check-in library for Android using MapBox SDK
https://ona.io
BSD 2-Clause "Simplified" License
18 stars 13 forks source link

Support defining how the icon changes when a point is touched on the map #189

Open craigappl opened 5 years ago

craigappl commented 5 years ago

When a user touches the map, the point and possibly icon should change. The GeoWidget needs to support defining an "on tapped" style. This needs to support multiple geometry types (Point, Polygon)

For example a tapped point in Reveal highlights the GeoJSON polygon as orange: green point tapped 2

ekigamba commented 5 years ago

@craigappl Do you have an idea of how points should look like when selected and how they'll probably look before they are selected?

ekigamba commented 5 years ago

Style Approach

The following are ways on how to achieve all these:

  1. Add a select status as a property in the features. The layer layout filter for the select status will define how a feature with the select status will look like and all that has to happen is update the feature - Kujaku can then handle enabling of selection statuses on the map for specific layers once passed the param
  2. We can also have a select layer where we just add the selected feature to the select layer - Kujaku can move the selected feature to the select layer.

These two enable us to define most of the styling from a server(Mapbox studio or wherever this style will be living) and does not require a new release to make such changes - It's configurable easily and by default.

Programmatically

  1. The above can still be achieved by the host application in code
  2. The host application can programmatically define:
    • The UI element a. A color - We are going to draw a polygon(for polygons) or circle(circles and points) of that color b. Polygon coloring options - Define the fill color, default shape(if not the polygon shape) and stroke to use for selected features
    • Layers which are selectable
    • The selection mode a. Selecting another feature can disable selection of the previous feature b. Multiple features can be selected. To deselect a feature, you click on it again.

This approach will use a Builder pattern

  1. The host application can do this itself in code so that they have more power over how all of this looks like - This works for situations where special UI for the selected features is required and we ascertain that we cannot figure out a configurable API to add this

@githengi @manutarus Do you have any input/ideas on this?

craigappl commented 5 years ago

@craigappl Do you have an idea of how points should look like when selected and how they'll probably look before they are selected?

@rowo , do you have any thoughts on this? The UI mock-ups show the color orange. I think we should have a visual indicator. In Google maps, they show the icon much larger than all of the other icons on the map to signify that is the one that's selected. image

@ukanga is there a precedent we can use from mSpray?

githengi commented 5 years ago

@ekigamba the first option if possible will be the best option. If its not possible we can use Programmatic approach

ekigamba commented 5 years ago

Cool, I'll look into how that is possible within the style via approach no. 1 depending on the results of https://github.com/onaio/kujaku/issues/158.

rowo commented 5 years ago

@craigappl I had created a special more prominent visual indicator but I think Matt or Derek nixed that and said that they appeared orange in mSpray or OMK or whatever. That's for structures. For points, we could still use it since it doesn't have a specified shape — but i wonder if that would get confusing with people thinking there's a hot air balloon shaped structure somewhere.

craigappl commented 5 years ago

@ekigamba and @rowo , points seem to show up as circles right now, not balloons. Let's keep it as it is and just change the color following what's in mSpray.

ekigamba commented 5 years ago

@githengi @craigappl We'll go with this option as @githengi requested

We can also have a select layer where we just add the selected feature to the select layer - Kujaku can move the selected feature to the select layer.

The only difference being that this will have to be done in the host application since this is not an API thing.

I have updated the current reveal style to have a select layer with the id select-layer and fill color for the polygons as orange.

Due to the nature of the select feature currently, I think it is better if it's handled by the host application(Reveal) until when we can establish a clearer and more acceptable API that can be added to the widget. If it were to be added to the widget it would need a lot more work to make it configurable with other conventional strategies for such a feature. I wrote sample code to show how this can be achieved here https://github.com/onaio/kujaku/pull/204 since it requires a few lines of code

Is this ok with everyone?