Feature/fit to coordinates#545
Conversation
|
@naoufal wow, this looks really good! Is there any way you'd be willing to tackle adding this API to android as well? We are trying our best to keep this component have feature parity cross-platform. |
|
@lelandrichardson Yeah, I can give it a shot this weekend. What are you thoughts on |
components/MapView.js
Outdated
There was a problem hiding this comment.
What do you think about providing default arguments? Something like:
fitToCoordinates(coordinates, edgePadding = {}, animated = true) {There was a problem hiding this comment.
@spikebrehm I initially had { top: 0, right: 0, bottom: 0, left: 0 } as a default argument, but then realized setVisibleMapRect could be called without edgePadding altogether. So I moved the conditional to the native side.
I don't mind switching to the default argument instead, whatever you guys prefer -- I'm easy.
There was a problem hiding this comment.
Maybe we could also add some documentation to this method that explains the possible keys of edgePadding. Either with a comment, or again using default arguments as documentation:
fitToCoordinates(coordinates, edgePadding = { top = 0, right = 0, bottom = 0, left = 0 }, animated = true) {There was a problem hiding this comment.
@spikebrehm I'll update it to use the default arguments.
As for additional documentation, I included an EdgePadding type to the MapView docs
|
Looks really nice! I'm partial to just a single |
|
@spikebrehm I'm also for a single |
|
|
|
@naoufal Let me know if you'd like any assistance with the Android stuff! This would be a great feature for sure. I implemented similar behavior for my project in JS but if we can make it a native feature of the plugin, all the better. |
|
@chrisknepper That'd be great! I'm struggling to get my Android environment setup. You can get in touch with me on the Reactiflux chat if you have any questions. |
|
@naoufal I think I have gotten this working on Android (except for |
|
@chrisknepper Looks great! |
There was a problem hiding this comment.
Whoops, forgot to remove that last night 😪
|
@chrisknepper Is the Android part ready for review? |
There was a problem hiding this comment.
@chrisknepper You're missing a space after your if on line 566.
|
@naoufal It is now ready for review. I'm not sure where the conflicts are but we should merge in the latest from here into your fork. |
ab63b62 to
7742e6c
Compare
|
@spikebrehm, @lelandrichardson Alright, so I updated my changes based on the feedback provided, added an example to the main README and rebased off master to resolve the conflicts. @chrisknepper and I have both tested the example on our respective Android and iOS environments. Can you run the examples on your machines and let me know if there's anything else I can do to help move this PR forward. |
|
I have one suggestion for this. IMO, This results in the call looking like this: This isn't a big deal and is just a semantics preference, but I envision this being frequently used without |
|
I'm in favour of keeping I'd like to hear @spikebrehm and @lelandrichardson's thoughts on this. |
|
Boolean parameters make me sad. I wonder if a better approach is
Just an idea. What do you all think? |
|
Also: note there's a merge conflict in |
|
@lelandrichardson an @spikebrehm Conflicts keep popping up as other PRs get merged in. I'm going to hold off fixing them until we've decided on the final API to avoid duplicating work. |
|
In #495 I was working on adding props to the map component to set pixel insets. The work there isn't complete, but I'm wondering if maybe having those inset props and a |
@naoufal sounds good! @lelandrichardson and I can migrate the other methods to take |
Good point! If this gets merged before #495, we can cut a new release that utilizes pixel insets. @naoufal let's go with the |
|
@spikebrehm Sounds good to me. I'll make the changes tonight and ping you 👍 |
df63ec5 to
be02f25
Compare
be02f25 to
1e81b06
Compare
|
@spikebrehm Added the |
|
Beautiful, thank you! 🍻 |
|
@naoufal I'm trying to use fitToCoordinates but without success. I'm on Mac OS and building to an iOS simulator. I can add markers but this method doesn't work. Here it's part of my code: `const MARKER_COORDINATES = [ {latitude: -27.570351,longitude: -48.513944}, ... const DEFAULT_PADDING = { top: 40, right: 40, bottom: 40, left: 40 }; export default class TesteMapa extends Component { fitAllMarkers() { ` I can see the log messages, etc. What am I missing? Thanks |
|
Zoom level is too bug, when passing only one coordinate |
…coordinates Feature/fit to coordinates

Overview
fitToCoordinatesmethod to<MapView />Demo
Why?
I'm implementing a UI that requires the map to focus on a polyline or mix of polyline and markers. The current
fitToSuppliedMarkersmethod comes short as it only supports markers. At first, I thought about adding andidentifierprop to polylines, but I decided against it since one might want to focus on a specific part of a polyline. I settled on coordinates as I feel it's a more flexible API that covers a wider range of use cases.Questions
I can see some people omitting
edgePaddingwhich would have function calls look likefitToCoordinates(coords, null, true). It's not the prettiest, so I was hoping to get feedback on adding a second method for developers that requireedgePadding. Something like:To do