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

Add marker in source #2552

Closed
ghost opened this issue May 10, 2016 · 5 comments
Closed

Add marker in source #2552

ghost opened this issue May 10, 2016 · 5 comments

Comments

@ghost
Copy link

ghost commented May 10, 2016

Hi,

How to replicate the same code with Mapbox GL ? I would like to add some dynamic marker in one Source.

var markers = new L.MarkerClusterGroup();

    for (var i = 0; i < 10; i++) {
        var title = 'test1';
        var marker = L.marker(new L.LatLng(a[0], a[1]), {
            icon: L.mapbox.marker.icon({'marker-symbol': 'post', 'marker-color': '0044FF'}),
            title: title
        });
        marker.bindPopup(title);
        markers.addLayer(marker);
    }
    map.addLayer(markers);

Thank you

@lucaswoj
Copy link
Contributor

Hi @JSMap!

Fundamentally, "markers" are an idea from image tiled maps that don't make as much sense for vector maps. In a vector map, you can create "markers" with a GeoJSON source and a symbol layer.

Duplicate of #656

@ghost
Copy link
Author

ghost commented May 10, 2016

OK but do you have a solution to add a geojson feature to the source?

@lucaswoj
Copy link
Contributor

lucaswoj commented May 11, 2016

see GeoJSONSource#setData

@kylebebak
Copy link

kylebebak commented Dec 28, 2017

@lucaswoj
This link is broken.

Adding markers to a map is really basic functionality. I put it to you that most people, if they knew how difficult it is to render a few hundred markers with custom styles to a map, wouldn't even consider using Mapbox for a project.

The attitude I've seen in these issues regarding markers is really disconcerting, and will ensure that a lot of users migrate to Google Maps.

@mollymerp
Copy link
Contributor

I've fixed the link above, and here are two more examples of how to add markers (both DOM elements, and symbol layers) in gl-js
https://www.mapbox.com/mapbox-gl-js/example/custom-marker-icons/
https://www.mapbox.com/mapbox-gl-js/example/geojson-markers/

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

No branches or pull requests

3 participants