-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature request... configure initial map position #8
Comments
I think this would be a really nice addition and that an option to specify initial starting coordinates and zoom of the Map might be the best way to go. While I like the idea of the view fitting the route automatically, providing a route is an optional Shortcode parameter at this time. These Settings will need to get passed to JavaScript front-end to configure the Map on page load. At the moment it looks like that happens here. I think it might be worth refactoring the I hope that is somewhat useful. Thanks again! |
It looks like this line in assets/js/shortcode.js controls the initial map frame: map_l.fitBounds(data_layer.getBounds()); Is that correct? |
Yes. That line adjusts the Leaflet Map view to fit the |
I added in a couple of lines to hard code in some coordinates to set the bounds to. I built the package with grunt and verified that the changed code made it into the zip file in both shortcode.js and shortcode.min.js. I deactivated and deleted the old version of the plugin in wordpress. I uploaded the new version, but my new code isn't getting loaded - when I get into the browser console, I see the old code. Any idea what I'm doing wrong? edit: tried again this morning and it loaded. Must have been a client side caching thing. |
Hi Joe - as with the other feature, I'm not going to able to apply the time needed to make this into an actually useful feature. For my purposes, hardcoding the coordinates is sufficient. I'll share the URL to the website I'm working on once I get it done if you're interested. To set the bounds of the map to what I wanted, I made this change to shortcode.js: //map_l.fitBounds(data_layer.getBounds());
var southEast = inmap_L.latLng(37.233168, -76.498990),
northWest = inmap_L.latLng(46.206390, -123.885552),
bounds = inmap_L.latLngBounds(southEast, northWest);
map_l.fitBounds(bounds); I would guess that getting a southEast and nortWest point put into settings and passed to the client side would be relatively straightforward. |
Hi @mmcc-xx, Understood and thanks again for the feature request! I also appreciate you raising the issues you encountered with the build process. When I get time I will look in to improving... or more likely overhauling this and hopefully improving the "developer experience". I have left some comments on your PR just FYI. Cheers, Joe |
Hi @mmcc-xx, One of my changes in v2.0.0 of the plugin, currently available for testing on the staging branch (release notes here) is that if a Route is provided, the Map will now zoom to fit the bounds of the route and any track points. While not exactly the level of control you had requested, this does mean that the view of the Map can now be controlled by the Route provided. I hope this is of some use to you. More information here. All input greatly appreciated! ✌️ |
My use case for this plugin is sharing my son's progress as he cycles across the US this summer. When the map initially loads, I'd like to have it default to a view that shows the whole route instead of being zoomed in on the trip so far.
I have the route being imported from a geojson file, so I could imagine either setting the zoom based on the extents of the route, or allowing the extents to be set manually.
I'm happy to work on this, but some suggestions on how you'd like to see it implemented and where the change should be made would be appreciated.
Thanks!
The text was updated successfully, but these errors were encountered: