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

Add link to geodesic modes #1000

Merged
merged 2 commits into from
Aug 7, 2020
Merged

Add link to geodesic modes #1000

merged 2 commits into from
Aug 7, 2020

Conversation

zakjan
Copy link
Contributor

@zakjan zakjan commented Jul 30, 2020

I have created geodesic modes plugin. Most of the modes simply inherit from the original MapboxDraw modes, and wrap toDisplayFeatures function with geodesic calculation.

const DrawLineString = MapboxDraw.modes[Constants.modes.DRAW_LINE_STRING];

const DrawLineStringGeodesic = { ...DrawLineString };

DrawLineStringGeodesic.toDisplayFeatures = function(state, geojson, display) {
  const displayGeodesic = (geojson) => {
    const geodesicGeojson = createGeodesicFeature(geojson, { ctx: this._ctx });
    geodesicGeojson.forEach(display);
  };

  DrawLineString.toDisplayFeatures.call(this, state, geojson, displayGeodesic);
};

There is also a static mode which can be used to render geodesic map features without using the drawing capabilities. It is useful because geodesic calculations are isolated inside the plugin, keeping user code abstracted away from the calculations.

Related to mapbox/mapbox-gl-js#3544

@asheemmamoowala asheemmamoowala merged commit a32b418 into mapbox:main Aug 7, 2020
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.

2 participants