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

Provide a useful default style #1669

Merged
merged 1 commit into from Feb 20, 2014
Merged

Provide a useful default style #1669

merged 1 commit into from Feb 20, 2014

Conversation

tschaub
Copy link
Member

@tschaub tschaub commented Feb 19, 2014

Currently, the ol.feature.defaultFeatureStyleFunction results in nothing being rendered. I think we'll end up with fewer confused users if we either require a styleFunction to be provided, or provide a useful default.

@bartvde
Copy link
Member

bartvde commented Feb 13, 2014

I agree this makes sense, and will lead to less confusion

@twpayne
Copy link
Contributor

twpayne commented Feb 17, 2014

The following comment uses stroke styles as an example, but it equally applies to fill styles, text styles, and the various combinations of the presence or otherwise of each type of style.

With no default stroke style, there are two states.

  1. The user supplied a stroke styles, so use it for rendering.
  2. The user did not supply a stroke style, so don't render strokes.

With a default stroke style, there are three states:

  1. The user supplied a style, so use it for rendering.
  2. The user did not supply a stroke style, so don't render strokes.
  3. The user did not supply a stroke style, so render strokes using the default stroke style.
    Distinguishing between states (2) and (3) may require some careful coding.

In an early prototype version, we used an ol.style.Stroke to indicate a stroke style set by the user, null to indicate that no stroke should be drawn, and undefined to indicate that the default stroke style should be used. However, this code proved tricky to write and we abandoned it for the simpler two-state model of stroke/no stroke.

@tschaub
Copy link
Member Author

tschaub commented Feb 17, 2014

Understood. That would be an issue if we were trying to provide default symbolizers. I was talking about providing a default style function. See my default-style branch for a quick example. Basically, if the user provides anything, use it. If not, render something anyway.

@twpayne
Copy link
Contributor

twpayne commented Feb 17, 2014

OK, that makes sense. But why you no use BADA55 color ?

@tschaub
Copy link
Member Author

tschaub commented Feb 17, 2014

🤘

@tschaub
Copy link
Member Author

tschaub commented Feb 19, 2014

default-style

Clearly a subjective thing, but I think this is a suitable default style (this is the GeoJSON example without all the style cruft).

I'm inclined to clean up our examples to be more single purpose. For example, the GeoJSON example would use the default style (and wouldn't use ol.geom.Circle), we'd have dedicated examples showing the use of the style option with and without a function, etc.

Comments?

@twpayne
Copy link
Contributor

twpayne commented Feb 19, 2014

+1 from me. The GeoJSON example started as a test bed for all the different geometry types in GeoJSON, but as evolved into a base example where different geometry types are needed for demonstration/testing (e.g. the modify features example is based on it). So, there's a lot of cruft in there that can - as you say - be removed.

@elemoine
Copy link
Member

+1 from me as well.

@bartvde
Copy link
Member

bartvde commented Feb 20, 2014

I'd be interested to see what this looks like on a satellite type of base map but +1 from me as well

@tonio
Copy link
Member

tonio commented Feb 20, 2014

👍

@tschaub
Copy link
Member Author

tschaub commented Feb 20, 2014

I'd be interested to see what this looks like on a satellite type of base map but +1 from me as well

It looks pretty close to the existing vector layer example.

default-style2

We can continue tweaking this style - not critical to have it perfect right now, more important to have a place where the default is specified. In particular, I think we might want to have wider strokes for line geometries (and narrower for polygon), but this can be changed later.

@tschaub tschaub closed this Feb 20, 2014
@tschaub tschaub reopened this Feb 20, 2014
tschaub added a commit that referenced this pull request Feb 20, 2014
Provide a useful default style.
@tschaub tschaub merged commit 0692db7 into openlayers:master Feb 20, 2014
@tschaub tschaub deleted the default-style branch February 20, 2014 18:09
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

6 participants