-
Notifications
You must be signed in to change notification settings - Fork 67
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
Add locate me #171
Add locate me #171
Conversation
this adds enhancement #144 for a locate me feature
my first time installing node, grunt, etc - contribution instructions were great! 💯 locate feature references locate cdn with top left location - will need to add to css file for custom location. |
Sweeeeeeet! Thanks for doing this 💃 I'm working on a big overhaul in the Not sure why the checks are failing here, though. |
Will this add the location as a layer or only zoom to a persons location? It looks like just the latter? I think both are valuable, so thanks for putting this in! |
Ohhh location as a layer would be awesome. |
Just zooms to the persons location 😞 - the users location can probably be obtained from the marker or centroid extent, but that's beyond my skills (for now). i wasn't sure where to add the library to the project - there are a few css properties we can use to move the locate me button underneath the zoom in/out control. |
No sad faces! This is all 😄s. I've noted "turn user location into layer" as a bonus feature in the alpha and it can be unrelated to this PR. As for adding libraries, we've gone back and forth between using CDNs, |
ill wire it up to use npm & bundle 👍 |
Cool! |
Hey @jonahadkins it looks like there is a relatively quick way to do this using the |
Even better - Ill work on that then |
currently having beginner issues with this._map.locate(); throwing a |
@jonahadkins I wonder if the |
@jonahadkins Haven't had a time to actually checkout your code, but it sounds likes your
if (!navigator.geolocation) {
geolocate.innerHTML = 'Geolocation is not available';
} else {
var _this = this; // Assigning the old 'this' to a variable that won't be overwritten
geolocate.onclick = function (e) {
e.preventDefault();
e.stopPropagation();
_this._map.locate(); // Explicitely using the old 'this'
};
}
if (!navigator.geolocation) {
geolocate.innerHTML = 'Geolocation is not available';
} else {
geolocate.onclick = function (e) {
e.preventDefault();
e.stopPropagation();
this._map.locate();
}.bind(this); // Tells the function to use the provided 'this', not its own 'this'
} I'm no expert, but I feel like either of those should help. I think option 2 is a bit cleaner. Ps. Watch out for the indentation in that class. It's functionally the same, but a well indented chunk of code is much easier to read. |
Yes, thanks @alukach! The confusion of It will look more like this in var myLocation = dc.map.m.locate() // can use this anywhere, without referring to "this" |
omg y'all IT WORKS i do get this warning from chrome dev tools:
but IT WORKS |
aw paying money for https sounds like a fun way to spend my day |
So, allegedly you can set up SSL w/ custom domains for free: https://sheharyar.me/blog/free-ssl-for-github-pages-with-custom-domains/. |
Whoa. Nice! |
FYI - Everything Works - I think the button might need some JS help to stay put (the previous library we used did) |
this adds enhancement #144 for a locate me feature