rnmapbox / maps

A Mapbox react native module for creating custom maps
MIT License
2.26k stars 846 forks source link

Including a RectangleLayer component #543

Closed naftalibeder closed 4 years ago

naftalibeder commented 4 years ago

Is there a reason why there isn't a rectangle equivalent of CircleLayer? Would a PR with this component be accepted?

EricPKerr commented 4 years ago

This would help alleviate some of the issues with PointAnnotation being deprecated since a major draw for that was being able to include arbitrary View elements with freeform text, icons, images, etc.

mfazekas commented 4 years ago

@naftalibeder not sure ... CircleLayer is based on a native component see https://docs.mapbox.com/ios/api/maps/5.5.0/Classes/MGLCircleStyleLayer.html

Note sure what RectangeLayer would be?! There already fill style layer see https://github.com/react-native-mapbox-gl/maps/blob/master/docs/FillLayer.md https://docs.mapbox.com/ios/api/maps/5.5.0/Classes/MGLFillStyleLayer.html you can draw rectangles with that.

I'm closing this now. Please clarify if I misunderstood something.

naftalibeder commented 4 years ago

@mfazekas As I understand it, ‘MGLFillStyleLayer‘ is defined so its borders are pinned in map space, not in screen space. ‘CircleLayer‘, in contrast, is centered in map space, but sized in the screen coordinate system, meaning as the map is zoomed, the circle remains the same size in pixels.

So currently, there doesn’t seem to be a way to draw a rectangle (or arbitrary shape) so that its size onscreen remains constant as the map is zoomed.

Am I wrong? If so, I’d love to hear how to do this. Otherwise, this does seem like an issue worth solving - as @EricPKerr said, ‘PointAnnotation‘ solved this perfectly, but is no longer supported.

mfazekas commented 4 years ago

@naftalibeder I don't think it's possible to implement a RectangleLayer as you're describing it. CircleLayer is a native concept and the RectangleLayer is non existent on native side. Also it would not solve adding arbitary view elements just rectangles.

So if the goal is adding view as markers/annotations then on android we could build something based on markerview, on ios it should not be an issue as I recall.