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

Marker is not working #22

Closed
eraysezginer opened this issue May 28, 2018 · 1 comment
Closed

Marker is not working #22

eraysezginer opened this issue May 28, 2018 · 1 comment

Comments

@eraysezginer
Copy link

eraysezginer commented May 28, 2018

Hello,

I try to use simple marker (and other kind of mapbox features like LineString) but it's not showing on the map.Here is the code ;

    var map = new mapboxgl.OfflineMap({
        container: 'map',
         style: 'styles/osm-bright/style-offline.json',
        center: [2.15, 41.38],
        zoom: 8
    });

    var marker = new mapboxgl.Marker()
      .setLngLat([2.15, 41.38])
      .addTo(map);

But when I switch to online version with same code (OfflineMap-->Map) it works and shows the marker ;

    var map = new mapboxgl.Map({
        container: 'map',
         style: 'styles/osm-bright/style-offline.json',
        center: [2.15, 41.38],
        zoom: 8
    });

    var marker = new mapboxgl.Marker()
      .setLngLat([2.15, 41.38])
      .addTo(map);

What could be the reason, any idea?

Thank you

@oscarfonts
Copy link
Owner

oscarfonts commented May 28, 2018

See README: OfflineMap returns a promise, not a map directly. Try this:

var map = new mapboxgl.Map({
    container: 'map',
    style: 'styles/osm-bright/style-offline.json',
    center: [2.15, 41.38],
    zoom: 8
}).then(function(map) {
    var marker = new mapboxgl.Marker()
      .setLngLat([2.15, 41.38])
      .addTo(map);
})

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

2 participants