JS 9

  • mapbox datasets

  • mapbox styles

We use Mapbox studio to design map styles trougth tilesets and GEOjson data.

//GEOjson to rappresent map data: 

{
  "features": [
    {
      "type": "Feature",
      "properties": {
        "title": "Lincoln Park",
        "description": "A northside park that is home to the Lincoln Park Zoo"
      },
      "geometry": {
        "coordinates": [-87.637596, 41.940403],
        "type": "Point"
      }
    }]
}

features.geometry(coordinates) and features.properties(other data)

Datasets are editable collections of GEOjson:

here we can draw new points and add features.properties to it, (title and description) or upload a GEOjson

We export the dataset to create a new Tileset, a map is divided into tiles for performance.

Tilesets are used as source in map style layers (where we can add symbol custom icons).

After we style the layer

After making our style public on mapbox studio we can also use its tileset source:

this PopUp could be edited trought its css .mapboxgl-popup-content

We can add a flyTo animation effect between the points :

MapBox Markers, events, and properties

The Marker component can take a property argument object:

For Marker() events we use on():

We can also use Geojson for the Markers data:

each is a DIV element in the map

Mapbox PopUps, properties, and events.

First, let's see how to bind a Popup to a Merker:

Remember that Popup() doesn't have the element property:

Now for the Popup Properties:

And for the PopUp Event and Instance members:

We can have events on Markers used on Popup instance:

on Marker event we GET and use it on Popup

Style Geojson sources with Mapbox layers

We add the Geojson as a source (with ID):

Circle stroke is the border

For the Popup on Hover :

We also need to include a remove() Popup on Hover off:

We can use Mapbox data in our source:

yet to see if their color can be changed

The code is the same as the Hover:

Last updated