Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Add Circle (with radius expressed in physical units) #4312

Closed

Description

@tobrun

A circle on the earth's surface on a specific LatLng as center.
iOS equivalent: #2167

Activity

  1. added
    Android
    on Mar 14, 2016
  2. tmcw commented on Mar 14, 2016

    @tmcw
    Contributor

    Given that there are circles defined from

    • Pixel radius
    • Meter radius, but always a circle in mercator
    • Meter radius, and actually a spherical cap, so sometimes oblong on mercator

    We should have a solid vocabulary that helps differentiate from the beginning.

  3. tobrun commented on Mar 14, 2016

    @tobrun
    MemberAuthor

    I created this issue for parity with gmaps. There they define this circle as sperical cap.

  4. zugaldia commented on Sep 15, 2016

    @zugaldia
    Member

    We're in a good position now to add this API. Meanwhile, we currently have three workarounds:

  5. 1ec5 commented on Sep 15, 2016

    @1ec5
    Contributor

    Note the differences between the three approaches: the polygon approach in #2167 (comment) is for a circle whose radius corresponds to a physical ground distance, whereas the MarkerView and CircleLayerActivity approaches are for circles whose radii correspond to fixed screen distances, regardless of the zoom level or latitude.

  6. added
    Google Maps parity
    on Aug 11, 2017
  7. bilthon commented on Aug 18, 2017

    @bilthon

    Using a polygon feels like a hackish workaround. This feature should really be supported at the native level.

  8. tobrun commented on Aug 18, 2017

    @tobrun
    MemberAuthor

    Circles are supported through CircleLayer, we do not expose an annotation API for it atm.

  9. bilthon commented on Aug 18, 2017

    @bilthon

    The problem I have with the CircleLayer right now is that the only way I found of creating a circle with dynamic in-app data is using a geoJSON source. But geojson doesn't seem to allow us to specify a circle. https://stackoverflow.com/questions/16942697/geojson-circles-supported-or-not

  10. zugaldia commented on Aug 21, 2017

    @zugaldia
    Member

    The problem I have with the CircleLayer right now is that the only way I found of creating a circle with dynamic in-app data is using a geoJSON source. But geojson doesn't seem to allow us to specify a circle.

    For a CircleLayer is enough if you set a point to indicate the center of the circle. For example, you could create a GeoJsonSource with:

    GeoJsonSource geoJsonSource = new GeoJsonSource("circle-source",
        Point.fromCoordinates(Position.fromLngLat(-0.07520, 51.50550)));
    mapboxMap.addSource(geoJsonSource);
    

    And then use the CircleLayer to visualize it:

    CircleLayer circleLayer = new CircleLayer("circle-layer", "circle-source");
    circleLayer.setProperties(
        PropertyFactory.visibility(Property.VISIBLE),
        PropertyFactory.circleRadius(25f),
        PropertyFactory.circleColor(Color.argb(1, 55, 148, 179)));
    mapboxMap.addLayer(circleLayer);
    

    If you need more control over the circle, another option you might want to look into is the SymbolLayer. The LocationLayer plugin is a good example of it.

  11. 1ec5 commented on Aug 21, 2017

    @1ec5
    Contributor

    @tobrun @zugaldia, please note that there’s a fundamental difference between the kind of circle drawn by CircleLayer (whose radius is expressed in screen units) and the kind of circle that’s tracked in this ticket (whose radius corresponds to a physical distance). Please refer to #4312 (comment). This is still a valid feature request, although there’s a tension between implementing this very useful feature while at the same time conforming to the Simple Features specification and GeoJSON.

  12. changed the title [-]Add Circle[/-] [+]Add Circle (with radius expressed in physical units)[/+] on Aug 21, 2017
  13. added
    archived
    on Nov 4, 2018
  14. stale commented on Dec 1, 2018

    @stale

    This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

  15. removed
    archived
    on Feb 14, 2019
  16. jrgonzalezg commented on Feb 22, 2019

    @jrgonzalezg

    Now there seems to be annotation support for circles using CircleOptions and CircleManager. And the CircleOptions seem quite similar to the Google Maps version, but unlike the behavior on Google Maps it seems that the radius here is using screen pixels instead of meters and the circle does not properly scale with zoom. Workarounds like sampling the circumference and using a polygon with FillManager work but require quite a bit of boilerplate. Also I don't really understand what's the purpose of CircleManager / CircleOptions working that way with radius in device pixels and ignoring zoom changes. Will it be possible to fix this to work as Google Maps (if there aren't any valid use cases for the current behavior) or to provide a variant that works like in Google Maps?

  17. androideveloper commented on Mar 5, 2019

    @androideveloper

    Coming from Google Maps and found the same issue. Any updates on this?

  18. tobrun commented on Apr 15, 2019

    @tobrun
    MemberAuthor

    First step to implement this feature is supporting http://turfjs.org/docs/#circle in the java port of turf. This is ticketed in mapbox/mapbox-java#1002.

    edit: that functionality is already implemented so this should already be possible today. Will create a small example around this.

    edit: ezgif com-video-to-gif (58)

  19. miladsalimiiii commented on Dec 14, 2021

    @miladsalimiiii

    The problem I have with the CircleLayer right now is that the only way I found of creating a circle with dynamic in-app data is using a geoJSON source. But geojson doesn't seem to allow us to specify a circle.

    For a CircleLayer is enough if you set a point to indicate the center of the circle. For example, you could create a GeoJsonSource with:

    GeoJsonSource geoJsonSource = new GeoJsonSource("circle-source",
        Point.fromCoordinates(Position.fromLngLat(-0.07520, 51.50550)));
    mapboxMap.addSource(geoJsonSource);
    

    And then use the CircleLayer to visualize it:

    CircleLayer circleLayer = new CircleLayer("circle-layer", "circle-source");
    circleLayer.setProperties(
        PropertyFactory.visibility(Property.VISIBLE),
        PropertyFactory.circleRadius(25f),
        PropertyFactory.circleColor(Color.argb(1, 55, 148, 179)));
    mapboxMap.addLayer(circleLayer);
    

    If you need more control over the circle, another option you might want to look into is the SymbolLayer. The LocationLayer plugin is a good example of it.

    Did you try this ?! for draw circle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    AndroidGoogle Maps parity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions