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

Enable property functions for icon-rotate #2738

Merged
merged 4 commits into from
Jun 15, 2016

Conversation

lucaswoj
Copy link
Contributor

@lucaswoj lucaswoj commented Jun 14, 2016

@lbud
Copy link
Contributor

lbud commented Jun 14, 2016

@danpat!

@jfirebaugh
Copy link
Contributor

The rendering looks pixelated:

image

Is this another case where we need to switch to linear texture interpolation rather than nearest?

@lucaswoj
Copy link
Contributor Author

Is this another case where we need to switch to linear texture interpolation rather than nearest?

Yes, I will look into this now.

@lucaswoj
Copy link
Contributor Author

Just built a fun demo using http://restbus.info/ (thanks @peterqliu @ericfischer!)

This demo really highlights the need for better interpolation 😄

http://bl.ocks.org/lucaswoj/raw/ce18d1fb581a229624fb84c5549eb899/

screen shot 2016-06-14 at 1 56 15 pm

@lucaswoj
Copy link
Contributor Author

Pushed a new commit and (updated the demo) to use linear interpolation for rotated icons

@danpat
Copy link

danpat commented Jun 14, 2016

@jfirebaugh
Copy link
Contributor

That looks great!

@lucaswoj lucaswoj force-pushed the icon-rotate-property-function branch from 2929d57 to eab9deb Compare June 15, 2016 17:28
@lucaswoj lucaswoj force-pushed the icon-rotate-property-function branch from 801ad95 to 9832cde Compare June 15, 2016 18:54
@lucaswoj lucaswoj merged commit 6f797c2 into master Jun 15, 2016
@lucaswoj lucaswoj deleted the icon-rotate-property-function branch June 15, 2016 19:14
@swratten
Copy link

@lucaswoj is there a way for me to individually rotate icons in the FeatureCollection like in: http://bl.ocks.org/lucaswoj/ce18d1fb581a229624fb84c5549eb899

That is, instead of the entire set of icons.

I am using: v0.20.1

I have tried copy pasting the relevant code from that blocks url and the result does not reflect what resides in the url provided.
mapbox-restbus

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Jun 28, 2016

@swratten I cannot see anything wrong with your code as posted. Please open a question on Stack Overflow with a functioning demo.

@lucaswoj
Copy link
Contributor Author

@swratten My apologies. The problem is that property functions for icon-rotate hasn't yet been released. Expect a release sometime this week! In the interim, you may use a build of master https://github.com/mapbox/mapbox-gl-js/blob/master/CONTRIBUTING.md#creating-a-standalone-build

@swratten
Copy link

No problem, thanks for that the master build works perfectly cheers!

davidtheclark pushed a commit that referenced this pull request Jul 1, 2016
* Pass entire style layer to functions within quads.js

* Enable property functions for icon-rotate

* Use linear interpolation for rotated icons

Update test-suite

* Update package.json
@dvonlehman
Copy link

dvonlehman commented Jul 11, 2016

Do property functions work for the text-anchor style property? Trying to do something like the following:

map.addLayer({
  layout: {
    'text-anchor': {
       property: 'textAnchor',
       stops: [
          ['top-left', 'top-left'],
          ['top-right', 'top-right']
        ]
     }
  }
});

Where the feature object has a textAnchor property. Really in my case the stops are not relevant, it'd be cleaner were it possible to simply pull in the value of a feature property like you can do with {title}.

map.addLayer({
  layout: {
    'text-anchor': '{textAnchor}'
  }
});

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Jul 11, 2016

@dvonlehman Please see https://www.mapbox.com/mapbox-gl-style-spec/, which now lists the current status of data-driven styling support.

@ilyatrunov
Copy link

I'm on version 0.22, still no support for "icon-rotate" from properties
Error: layout.icon-rotate: number expected, string found

@danpat
Copy link

danpat commented Sep 20, 2016

@ilyatrunov icon-rotate data driven styling is available in 0.23 and onwards.

@ilyatrunov
Copy link

@danpat ok, can you please update the version here:
https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-icon-rotate
it is also appears in release notes for 0.21

thank you

@danpat
Copy link

danpat commented Sep 20, 2016

Sorry, my bad, it works from 0.21 and onwards. @ilyatrunov can you paste a sample of your style? It sounds like you might have the syntax wrong.

@ilyatrunov
Copy link

ilyatrunov commented Sep 20, 2016

@danpat
map.addLayer({
id: id,
source: id,
type: 'symbol',
layout: {
'icon-image': "harbor-15",
'icon-rotate': '{heading}'
})

my data set has a "heading" property in "properties". and it's numeric.

I've updated to v0.24, but still - same error

@jfirebaugh
Copy link
Contributor

@ilyatrunov The interpolated string syntax is only for icon-image and text-field. Data-driven styling uses property functions and zoom-and-property functions. See here for an example.

@ilyatrunov
Copy link

@jfirebaugh thank you! it's all good now. can this be added to the documentation, for the people who will need this? thanks again!

@ilyatrunov
Copy link

I used intervals of 30 deg, like this:
stops: [
[0, 0], [30, 30], [60, 60], [90, 90],
[120, 120], [150, 150], [180, 180], [210, 210],
[240, 240], [270, 270], [300, 300], [330, 330], [360, 360]
]

On Wed, Sep 28, 2016 at 3:55 PM, Simona [email protected] wrote:

Hey guys,
not sure I'm getting it anyways. I read about property function here, so
if ilyatrunov has a property 'heading', and it could be anything between 0
and 360, icon-rotate property should look something like this?

'icon-rotate': {
'property': 'heading',
'stops': [
[0, 0],
[1, 1]
and so on till 360?
]
}

I must be wrong since that would be really long array. But I didn't find
anything about intervals/ranges in the documentatio. Could you help me out
on this, @jfirebaugh https://github.com/jfirebaugh or @ilyatrunov
https://github.com/ilyatrunov ?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#2738 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQnd1gs0rAHF5qgLwC4aTrwyXRp7IRLnks5qumPOgaJpZM4I1tVv
.

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Oct 5, 2016

@ilyatrunov The stops are interpolated so you should only need to include stops: [[0, 0], [360, 360]]

@rlanda123
Copy link

@jfirebaugh Hi, would you please help me in finding a solution for my problem? I am trying to bind the icon-rotate property to one of the properties called "heading" in my feature. It is not working and I am not sure how to proceed further. Please see the following:
map.addLayer({
"id": "tracks",
"type": "symbol",
// Add a GeoJSON source containing place coordinates and information.
"source": 'trace',
"layout": {
"icon-image": "airport-15",
"icon-allow-overlap": true,
"icon-rotate" :{heading},
"text-field": "{name}",
"text-font": ["Open Sans Semibold", "Arial Unicode MS Bold"],
"text-offset": [0, 0.6],
"text-anchor": "top"
}
});

I would greatly appreciate if you could please point me to a right direction. Thank you so much in advance.

@lbud
Copy link
Contributor

lbud commented Feb 6, 2018

@rlanda123 the {token syntax} is only for text-field and icon-image, as noted above; see "identity functions" in the documentation for your use case. In the future please direct "how do I" questions to StackOverflow.

@rlanda123
Copy link

@lbud Thank you soooooo much for your help. I used the identity function as you suggested like below and it works now! I have no words to express my thanks to you. Thanks million for your quick response.
For those of who, who is struggling: here is my updated code:

map.addLayer({
       "id": "tracks",
       "type": "symbol",
       // Add a GeoJSON source containing place coordinates and information.
       "source": 'trace',
       "layout": {
           "icon-image": "airport-15",
           "icon-ignore-placement": true,
           "icon-allow-overlap": true,
           "icon-rotate" : {
               "type" : "identity",
               "property": "heading",
               "default" : 90
           },
           "text-field": "{name}",
           "text-font": ["Open Sans Semibold", "Arial Unicode MS Bold"],
           "text-offset": [0, 0.6],
           "text-anchor": "top"
       },
       "paint" : {
           "icon-opacity" : 1
       }
   });

@rlanda123
Copy link

rlanda123 commented Feb 6, 2018 via email

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.

Enable property functions for "icon-rotate"
8 participants