logo
leafmap
Geojson points
Initializing search
    GitHub
    GitHub
    • Home
    • Book
    • Installation
    • Get Started
    • Usage
    • Web App
    • Tutorials
    • Contributing
    • FAQ
    • Changelog
    • YouTube Channel
    • Report Issues
      • basemaps module
      • bokehmap module
      • colormaps module
      • common module
      • deck module
      • deckgl module
      • download module
      • examples module
      • foliumap module
      • kepler module
      • maplibregl module
      • leafmap module
      • legends module
      • map_widgets module
      • osm module
      • pc module
      • plot module
      • plotlymap module
      • deck module
      • stac module
      • toolbar module
      • FOSS4G 2021
      • SIGSPATIAL 2021
      • YouthMappers 2021
      • ICRW 2023
      • EarthCube 2023
      • Taiwan 2024
      • HGAC 2024
      • Overview
      • 3d buildings
      • 3d choropleth
      • 3d indoor mapping
      • 3d pmtiles
      • 3d style
      • 3d terrain
      • Add 3d buildings
      • Add a marker
      • Add colorbar
      • Add components
      • Add deckgl layer
      • Add gif
      • Add html
      • Add icon
      • Add image
      • Add image generated
      • Add labels
      • Add legend
      • Add logo
      • Add text
      • Animate a line
      • Animate camera around point
      • Animate images
      • Animate point along line
      • Animate point along route
      • Attribution position
      • Basemaps
      • Center on symbol
      • Change building color
      • Change case of labels
      • Choropleth
      • Cloud optimized geotiff
      • Cluster
      • Color switcher
      • Countries filter
      • Create vector
      • Custom marker
      • Data driven lines
      • Disable scroll zoom
      • Display rich text
      • Drag a marker
      • Draw features
      • Edit vector
      • Fallback image
      • Fields of the world
      • Fit bounds
      • Fill pattern
      • Fly to
      • Fly to options
      • Fullscreen
      • Geojson layer in stack
      • Geojson line
      • Geojson points
      • Geojson polygon
      • Geopandas
      • Globe control
      • Google earth engine
      • Gps trace
      • Heatmap layer
      • Housing prices
      • Interactive false
      • Jump to
      • Language switch
      • Layer control
      • Layer manager
      • Layer styling
      • Line gradient
      • Live geojson
      • Live update feature
      • Local geojson
      • Local raster
      • Locate user
      • Map tiles
      • Mapillary
      • Maptiler styles
      • MGRS
      • Mouse position
      • Multiple geometries
      • Nasa opera
      • Navigation
      • Ocean bathymetry
      • Openfreemap
      • Openstreetmap
      • Overture
      • Pmtiles
      • Restrict bounds
      • Satellite map
      • Search control
      • Set pitch bearing
      • Sidebar
      • Stac
      • To html
      • Variable label placement
      • Variable offset label placement
      • Vector tile
      • Video on a map
      • Visualize population density
      • Wms source
      • Zoom to linestring
      • Usage
      • 01 leafmap intro
      • 02 using basemaps
      • 03 cog stac
      • 04 cog mosaic
      • 05 load raster
      • 06 legend
      • 07 colorbar
      • 08 whitebox
      • 09 csv to points
      • 10 add vector
      • 11 linked maps
      • 12 split map
      • 13 geopandas
      • 14 postgis
      • 15 openstreetmap
      • 16 heremap
      • 17 vector tile layer
      • 18 point layer
      • 19 map to html
      • 20 planet imagery
      • 21 ts inspector
      • 22 time slider
      • 23 colormaps
      • 24 heatmap
      • 25 map title
      • 26 kepler gl
      • 27 basemap gallery
      • 28 publish map
      • 29 pydeck
      • 30 census data
      • 31 search basemaps
      • 32 local tile
      • 33 image overlay
      • 34 add points from xy
      • 35 circle markers
      • 36 add labels
      • 37 planetary computer
      • 38 plotly
      • 39 inspector tool
      • 40 plotly gui
      • 41 raster gui
      • 42 create cog
      • 43 search control
      • 44 attribute table
      • 45 create vector
      • 46 edit vector
      • 47 numpy to cog
      • 48 lidar
      • 49 split control
      • 50 marker cluster
      • 51 clip image
      • 52 netcdf
      • 53 choropleth
      • 54 plot raster
      • 55 lidar
      • 56 download ned
      • 57 national map
      • 58 bokeh
      • 59 create legend
      • 60 add widget
      • 61 vector to gif
      • 62 folium colorbar
      • 63 arcgis
      • 64 stac search
      • 65 sagemaker
      • 66 gradio
      • 67 maxar open data
      • 68 openaerialmap
      • 69 turkey earthquake
      • 70 zonal stats
      • 71 aws s3
      • 72 timelapse
      • 73 custom stac
      • 74 map tiles to geotiff
      • 75 segment anything
      • 76 image comparison
      • 77 split raster
      • 78 read raster
      • 79 timeseries
      • 80 solar
      • 81 buildings
      • 82 pmtiles
      • 83 vector viz
      • 84 read parquet
      • 85 gedi
      • 86 add markers
      • 87 actinia
      • 88 nasa earth data
      • 89 image array viz
      • 90 pixel inspector
      • 91 raster viz gui
      • 92 maplibre
      • 93 maplibre pmtiles
      • 94 mapbox
      • 95 edit vector
      • 96 batch edit vector
      • 97 overture data
      • 98 watershed
      • 99 wetlands
      • 100 nlcd
      • 101 nasa opera
      • 102 fused
      • 103 raster colormap
      • 104 point style
      • 105 vector time slider

    image image image

    Draw GeoJSON points

    Draw points from a GeoJSON collection to a map.

    This source code of this example is adapted from the MapLibre GL JS example - Draw GeoJSON points.

    Uncomment the following line to install leafmap if needed.

    In [1]:
    Copied!
    # %pip install "leafmap[maplibre]"
    
    # %pip install "leafmap[maplibre]"
    In [2]:
    Copied!
    import leafmap.maplibregl as leafmap
    
    import leafmap.maplibregl as leafmap
    In [3]:
    Copied!
    m = leafmap.Map(center=[0, 0], zoom=1, style="positron")
    image = "https://maplibre.org/maplibre-gl-js/docs/assets/osgeo-logo.png"
    m.add_image("custom-marker", image)
    source = {
        "type": "geojson",
        "data": {
            "type": "FeatureCollection",
            "features": [
                {
                    "type": "Feature",
                    "geometry": {"type": "Point", "coordinates": [100.4933, 13.7551]},
                    "properties": {"year": "2004"},
                },
                {
                    "type": "Feature",
                    "geometry": {"type": "Point", "coordinates": [6.6523, 46.5535]},
                    "properties": {"year": "2006"},
                },
                {
                    "type": "Feature",
                    "geometry": {"type": "Point", "coordinates": [-123.3596, 48.4268]},
                    "properties": {"year": "2007"},
                },
                {
                    "type": "Feature",
                    "geometry": {"type": "Point", "coordinates": [18.4264, -33.9224]},
                    "properties": {"year": "2008"},
                },
                {
                    "type": "Feature",
                    "geometry": {"type": "Point", "coordinates": [151.195, -33.8552]},
                    "properties": {"year": "2009"},
                },
                {
                    "type": "Feature",
                    "geometry": {"type": "Point", "coordinates": [2.1404, 41.3925]},
                    "properties": {"year": "2010"},
                },
                {
                    "type": "Feature",
                    "geometry": {"type": "Point", "coordinates": [-104.8548, 39.7644]},
                    "properties": {"year": "2011"},
                },
                {
                    "type": "Feature",
                    "geometry": {"type": "Point", "coordinates": [-1.1665, 52.9539]},
                    "properties": {"year": "2013"},
                },
                {
                    "type": "Feature",
                    "geometry": {"type": "Point", "coordinates": [-122.6544, 45.5428]},
                    "properties": {"year": "2014"},
                },
                {
                    "type": "Feature",
                    "geometry": {"type": "Point", "coordinates": [126.974, 37.5651]},
                    "properties": {"year": "2015"},
                },
                {
                    "type": "Feature",
                    "geometry": {"type": "Point", "coordinates": [7.1112, 50.7255]},
                    "properties": {"year": "2016"},
                },
                {
                    "type": "Feature",
                    "geometry": {"type": "Point", "coordinates": [-71.0314, 42.3539]},
                    "properties": {"year": "2017"},
                },
                {
                    "type": "Feature",
                    "geometry": {"type": "Point", "coordinates": [39.2794, -6.8173]},
                    "properties": {"year": "2018"},
                },
                {
                    "type": "Feature",
                    "geometry": {"type": "Point", "coordinates": [26.0961, 44.4379]},
                    "properties": {"year": "2019"},
                },
                {
                    "type": "Feature",
                    "geometry": {"type": "Point", "coordinates": [-114.0879, 51.0279]},
                    "properties": {"year": "2020"},
                },
            ],
        },
    }
    
    m.add_source("conferences", source)
    layer = {
        "id": "conferences",
        "type": "symbol",
        "source": "conferences",
        "layout": {
            "icon-image": "custom-marker",
            "text-field": ["get", "year"],
            "text-font": ["Open Sans Semibold", "Arial Unicode MS Bold"],
            "text-offset": [0, 1.25],
            "text-anchor": "top",
        },
    }
    
    m.add_layer(layer)
    m
    
    m = leafmap.Map(center=[0, 0], zoom=1, style="positron") image = "https://maplibre.org/maplibre-gl-js/docs/assets/osgeo-logo.png" m.add_image("custom-marker", image) source = { "type": "geojson", "data": { "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [100.4933, 13.7551]}, "properties": {"year": "2004"}, }, { "type": "Feature", "geometry": {"type": "Point", "coordinates": [6.6523, 46.5535]}, "properties": {"year": "2006"}, }, { "type": "Feature", "geometry": {"type": "Point", "coordinates": [-123.3596, 48.4268]}, "properties": {"year": "2007"}, }, { "type": "Feature", "geometry": {"type": "Point", "coordinates": [18.4264, -33.9224]}, "properties": {"year": "2008"}, }, { "type": "Feature", "geometry": {"type": "Point", "coordinates": [151.195, -33.8552]}, "properties": {"year": "2009"}, }, { "type": "Feature", "geometry": {"type": "Point", "coordinates": [2.1404, 41.3925]}, "properties": {"year": "2010"}, }, { "type": "Feature", "geometry": {"type": "Point", "coordinates": [-104.8548, 39.7644]}, "properties": {"year": "2011"}, }, { "type": "Feature", "geometry": {"type": "Point", "coordinates": [-1.1665, 52.9539]}, "properties": {"year": "2013"}, }, { "type": "Feature", "geometry": {"type": "Point", "coordinates": [-122.6544, 45.5428]}, "properties": {"year": "2014"}, }, { "type": "Feature", "geometry": {"type": "Point", "coordinates": [126.974, 37.5651]}, "properties": {"year": "2015"}, }, { "type": "Feature", "geometry": {"type": "Point", "coordinates": [7.1112, 50.7255]}, "properties": {"year": "2016"}, }, { "type": "Feature", "geometry": {"type": "Point", "coordinates": [-71.0314, 42.3539]}, "properties": {"year": "2017"}, }, { "type": "Feature", "geometry": {"type": "Point", "coordinates": [39.2794, -6.8173]}, "properties": {"year": "2018"}, }, { "type": "Feature", "geometry": {"type": "Point", "coordinates": [26.0961, 44.4379]}, "properties": {"year": "2019"}, }, { "type": "Feature", "geometry": {"type": "Point", "coordinates": [-114.0879, 51.0279]}, "properties": {"year": "2020"}, }, ], }, } m.add_source("conferences", source) layer = { "id": "conferences", "type": "symbol", "source": "conferences", "layout": { "icon-image": "custom-marker", "text-field": ["get", "year"], "text-font": ["Open Sans Semibold", "Arial Unicode MS Bold"], "text-offset": [0, 1.25], "text-anchor": "top", }, } m.add_layer(layer) m

    2024-07-04 2024-06-23
    Copyright © 2021 - 2024 Qiusheng Wu
    Made with Material for MkDocs