Skip to content
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

Center on clicked symbol, addresses #1516 #1527

Closed
wants to merge 2 commits into from
Closed

Conversation

danswick
Copy link
Contributor

cc: @lyzidiamond

Would love some feedback on this example. Does it adequately replicate this popular Mapbox.js example?

marker-center

});

map.on('click', function(e){
map.featuresAt(e.point, { radius: 20, includeGeometry: true }, function(err, features){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    map.featuresAt(e.point, {layer: 'myMarkers', radius: 20, includeGeometry: true}, function (err, features) {
        if (err) throw err;
        if (features.length) {
            map.flyTo({center: features[0].geometry.coordinates});
        }
    });
  • Uses the layer option for featuresAt to avoid getting results for any other layers
  • Uses the coordinates from the marker itself, like the Mapbox.js example

Reference #1002 for a future API enhancement that would simplify this example to:

map.on('click', 'myMarkers', function (e) {
    map.flyTo({center: e.features[0].geometry.coordinates});
});

@danswick
Copy link
Contributor Author

Thanks for the note, @jfirebaugh! Added your suggestions and cursor change on hover to indicate markers are clickable (thanks, @edenh!).

Also just want to take everyone's temperature on terminology here. There isn't really a "marker" in GL, so I renamed this example "Center on symbol" to stick with GL terms. Does that make sense or is it even more confusing? I considered "Center on point," but that may be even worse. cc: @lyzidiamond.

@bhousel
Copy link
Contributor

bhousel commented Sep 25, 2015

Phrases like "marker", "layer", "control" are terms of art in Mapbox.js / Leaflet development, and I think it's best to carry them forward when speaking about Mapbox GL as well.

@lyzidiamond lyzidiamond mentioned this pull request Sep 25, 2015
@jfirebaugh jfirebaugh changed the title [DO NOT MERGE] Center on clicked symbol, addresses #1516 Center on clicked symbol, addresses #1516 Sep 26, 2015
@jfirebaugh
Copy link
Contributor

Committed to mb-pages in 28eca5a. Thanks!

@jfirebaugh jfirebaugh closed this Sep 26, 2015
@jfirebaugh jfirebaugh deleted the center-markers branch September 26, 2015 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants