-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
rotation based on attribute #873
Comments
👍, this is being tracked in mapbox/mapbox-gl-style-spec#105. |
For the benefit of anyone else who lands here you can now do this with dds identity function.
Unfortunately although Mapbox Studio has DDS support now, it doesn't look like the identity function support is there yet 😞 |
I see this issue as closed, but I still cant figure out how First method Layout property 'text-rotate': {
'type': 'identity',
'property': 'rotation'
}, Second method 'text-rotate': '{rotation}', |
@AbrahamArun From the example at #873 (comment) If your property is named
You shouldn't wrap it in braces like |
@andrewharvey That is exactly what I have done. The |
And this I am trying for |
@AbrahamArun Could you post a minimal jsbin example? |
@andrewharvey This is how my style layer looks: {
'id': 104,
'type': 'symbol',
'source': sourceId,
'paint': {
'text-color': black
},
'layout': {
'icon-allow-overlap': true,
'icon-ignore-placement': true,
'text-field': '{price}',
'text-rotate': {
'type': 'identity',
'property': 'rotation'
},
'text-max-width': 10,
'text-allow-overlap': true,
'text-ignore-placement': true,
'text-justify': 'center',
'text-size': {
'base': 1,
'stops': [[15, 2], [16.63, 8], [18, 20], [19, 40]]
}
,'text-offset':[0,-0.1]
},
}; Is this the right way to do it? |
Any solution to this? I have the same problem.
doesn't work |
@MartinHerich do you have a minimal jsbin example of it not working? |
OK. I found my way to use the field. Actually the problem was that MAPBOX changed the name of field from ORIENTATION to ORIENTATIO on import. Now it works. But I need to use formula on text-rotate as my values are in GONs with the beggining on south. My formula would be like |
I have a property named "heading". When I am trying to rotate the icon by binding the rotation property to heading, it is not working. Please see below: Can someone please help me how to make it work? |
@MartinHerich Did you have it working? If so, would you please post the addLayer()? Thanks a lot. |
Having the same issue as above: // Add current location marker
map.addSource('current-location', {
"type": "geojson",
"data": {
"type": "Point",
"coordinates": this.start,
"properties":{
"rotation":315
}
}
});
map.addLayer({
"id": "current-location-marker",
"source": "current-location",
"type": "symbol",
"layout": {
"icon-image": "sa-currentLocation",
"icon-size": 0.4,
"icon-padding":1,
"icon-allow-overlap":true,
"icon-anchor": "center",
"icon-pitch-alignment":"map",
//"icon-rotation-alignment":"map",
"icon-rotate": { "type": "identity", "property": "rotation" }
},
}); Not working: Working (without identity property, just static In my particular use case I am updating the icon pointer based upon an external NEMA GPS that gives a heading and more precise coordinates and need to issue MANY updates to the heading. |
Solved my own issue (hopefully others too). The single "Point" needed upgrading to a "Feature"
|
For me, the feature.properties.YOUR_STRING_PROP = +feature.properties.YOUR_STRING_PROP;
const angle = layer.layout.get('icon-rotate').evaluate(feature, {}) * Math.PI / 180; |
Hi. You can do something like
where AOO is an attribute that returns the angle of orientation. |
I have a ORIENTATION attribute in a feature that I want to use as the value to the "icon-rotate" attribute. Like this.
"layout": {
"icon-image": "triangle-12",
"icon-rotation-alignment": "map",
"icon-rotate": "{ORIENTATION}"
}
Is there a way to have a "Number" data type that is based on a attribute like the "String" data type does with {}? It does not seem to work for me now.
The text was updated successfully, but these errors were encountered: