Change the center of the map
See original GitHub issueHi,
I am trying to shift the center of the map a little bit up to make some space for overlay UI, so I used yOffset
for that but I get pretty weird results, i.e misplaced markers etc…
I pretty much follow the following example: https://www.react-simple-maps.io/with-react-motion
This is my projection configuration:
projectionConfig = {
yOffset: -150 / this.state.zoom
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Changing Map Center - Precisely Help
Changing Map Center · Look for the search box at the top left side of your screen. · Click or touch the search...
Read more >How to dynamically change the centre of a google maps ...
You can simply move the map with map.setCenter(LatLng) . This method will not use any other markers and will not erase existing markers....
Read more >Solved: How can I change/adjust the center of Map visual
Solved: HI I want to create a report wtih the Map visual, but the center of the Map is always London just like...
Read more >How do you get google maps to update search results as you ...
How do you get google maps to update search results as you change the ... You then move the center of the map...
Read more >Change center of map in OpenLayers dynamically
Is there a way to change the center of the map in OpenLayers dynamically? For example on button click. It would be too...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I solved the problem by adjusting the center.
Yeah, center is a geo coordinate that sets the focus of the map. It would achieve a similar result, i.e. moving your map up or down, depending on the coordinate that the map focuses on by default.
I am having trouble recreating the problem with
yOffset
and the misplaced markers. I tried this and it works. Am I missing something?It gives me a map that looks like this:
Note that if you added your own markers and they are misplaced, it may be that the order of longitude and latitude is reversed. I know this is an issue when working with coordinates from google and d3-geo. Google uses
[lat,long]
and d3-geo uses[long,lat]
.React-simple-maps
uses the d3-geo order. If this is the case, you would be getting very strange results, but if you are using the motion example with the markers that are included there, this shouldn’t be a problem…