Skip to content
This repository has been archived by the owner on Apr 10, 2018. It is now read-only.

Expand support for "*-pitch-alignment" and "*-size-alignment" #459

Closed
lucaswoj opened this issue Jun 9, 2016 · 9 comments
Closed

Expand support for "*-pitch-alignment" and "*-size-alignment" #459

lucaswoj opened this issue Jun 9, 2016 · 9 comments

Comments

@lucaswoj
Copy link

lucaswoj commented Jun 9, 2016

The style spec has the concept of rotation-alignment which specifies how features are placed with respect to map rotation.

  • rotation-alignment: viewport indicates that features should be rotated with respect to the viewport, drawn such that the top of the screen is "up".
  • rotation-alignment: map indicates that features should be rotated with respect to the map, drawn such that north is "up"

I propose that we add the concept of pitch-alignment which specifies how features are placed with respect to map pitch.

  • pitch-alignment: viewport indicates that features should be pitched with respect to the viewport, drawn on plane of the viewport.
  • pitch-alignment: map indicates that features should be pitched with respect to the map, drawn on plane of the map.

cc @yhahn @mourner @tmcw @ansis @jfirebaugh @lbud

@yhahn
Copy link
Member

yhahn commented Jun 9, 2016

rotation-pitch-alignment

👍 this makes total sense to me. It's worth noting that atm our renderers don't support this fully but it's something we can work toward.

master gl js/native

rotation pitch text support icon support
map map
map viewport
viewport map
viewport viewport

unskew gl js/native

rotation pitch text support icon support
map map
map viewport
viewport map
viewport viewport

I'll sketch this property out in the unskew branch and PR. @lucaswoj do you feel ok about partial support for this property being out in the wild in our renderers and chipping away at full support iteratively?

@lucaswoj
Copy link
Author

lucaswoj commented Jun 9, 2016

@lucaswoj do you feel ok about partial support for this property being out in the wild in our renderers and chipping away at full support iteratively?

Yup! I'd prefer that to designing our spec to around present partial renderer support.

@1ec5
Copy link
Contributor

1ec5 commented Jun 9, 2016

I’m implementing something similar for view-backed annotations on iOS in mapbox/mapbox-gl-native#5245. These properties will make it possible for gl-native to eventually support the same effects for GL point annotations too.

@jfirebaugh
Copy link
Contributor

jfirebaugh commented Jun 9, 2016

This is 👌 .

As a third complementary property, we'll want *-pitch-scale: {viewport,map} (mapbox/mapbox-gl-js#2541, mapbox/mapbox-gl-native#2186, mapbox/mapbox-gl-native#5040, mapbox/mapbox-gl-native#5169).

Full set of properties:

yhahn added a commit that referenced this issue Jun 11, 2016
* Add text-rotation-alignment, refs #459

* Unset default value of text-pitch-alignment, describe how default inheritance should behave. Refs #235
@johnnyluu
Copy link

johnnyluu commented Jun 20, 2016

Dear devs, is there a way for me to implement circle-pitch-alignment at the moment? I need some radius indicator on the map but the circles I added align with the viewport when I add pitch to the map, as shown in the image.

capture

@yeldarby
Copy link
Contributor

yeldarby commented Aug 17, 2016

@johnnyluu - if you are looking for a workaround, defining a polygon with GeoJSON instead of using the Mapbox-defined Circle works pretty well.

circle

Here is the function I wrote to generate the GeoJSON Polygon

var createGeoJSONCircle = function(center, radiusInKm, points) {
    if(!points) points = 64;

    var coords = {
        latitude: center[1],
        longitude: center[0]
    };

    var km = radiusInKm;

    var ret = [];
    var distanceX = km/(111.320*Math.cos(coords.latitude*Math.PI/180));
    var distanceY = km/110.574;

    var theta, x, y;
    for(var i=0; i<points; i++) {
        theta = (i/points)*(2*Math.PI);
        x = distanceX*Math.cos(theta);
        y = distanceY*Math.sin(theta);

        ret.push([coords.longitude+x, coords.latitude+y]);
    }
    ret.push(ret[0]);

    return {
        "type": "geojson",
        "data": {
            "type": "FeatureCollection",
            "features": [{
                "type": "Feature",
                "geometry": {
                    "type": "Polygon",
                    "coordinates": [ret]
                }
            }]
        }
    };
};

You can use it like this:

map.addSource("polygon", createGeoJSONCircle([-93.6248586, 41.58527859], 0.5));

map.addLayer({
    "id": "polygon",
    "type": "fill",
    "source": "polygon",
    "layout": {},
    "paint": {
        "fill-color": "blue",
        "fill-opacity": 0.6
    }
});

If you need to update the circle you created later you can do it like this (note the need to grab the data property to pass to setData):

map.getSource('polygon').setData(createGeoJSONCircle([-93.6248586, 41.58527859], 1).data);

@princeofnaxos
Copy link

+1

@lucaswoj lucaswoj changed the title Add the concept of "pitch-alignment" Expand support for "*-pitch-alignment" and "*-pitch-scale" Dec 22, 2016
@1ec5
Copy link
Contributor

1ec5 commented Jan 5, 2017

circle-pitch-scale, icon-pitch-scale, and text-pitch-scale should be renamed circle-scale-alignment, icon-scale-alignment, and text-scale-alignment, respectively: #645.

@lucaswoj lucaswoj changed the title Expand support for "*-pitch-alignment" and "*-pitch-scale" Expand support for "*-pitch-alignment" and "*-size-alignment" Jan 5, 2017
@lucaswoj
Copy link
Author

lucaswoj commented Feb 1, 2017

This issue was moved to mapbox/mapbox-gl-js#4120

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants