Leaflet Tutorial 5: Add GeoJSON using JavaScript

Поделиться
HTML-код
  • Опубликовано: 29 окт 2024
  • НаукаНаука

Комментарии • 13

  • @micahglenz1354
    @micahglenz1354 3 года назад +2

    Thanks for pointing out how the coords are reverse. Saved me a lot of time

  • @FatimaHABIB-jm4ji
    @FatimaHABIB-jm4ji Год назад +1

    Thanks for sharing, I have question, i have large GEOJSON file and i want to add information to a map dynamically as the user zooms in, how can I do that ?

  • @JeffreyKluitenberg
    @JeffreyKluitenberg 4 года назад +2

    Great short video! I've succesful added GeoJSON data in my map. But how can I change the default marker to a custom marker for the GeoJSON data?

    • @sabafatima1719
      @sabafatima1719 Год назад

      You can use this sample of code as reference:
      var myLines =
      {
      "type": "Feature",
      "geometry": {"type": "LineString","coordinates": [[51.50, -0.08], [51.51, -0.06],[51.52, -0.04]]}
      };
      var myStyle = { "color": "#FF0000", "weight": 9 };
      L.geoJSON(myLines, {style: myStyle}).addTo(map);

  • @eamontanner6778
    @eamontanner6778 11 месяцев назад

    So, my question is how do I remove myGeoJSON? I want to be able to toggle it on and off with a button.

  • @idriskodaolu4826
    @idriskodaolu4826 3 года назад

    thanks this saved me

  • @aislanarislou
    @aislanarislou 3 года назад

    How to add a circle representing the radius controlled by a slider inside the map ?

    • @maptilerofficial
      @maptilerofficial  3 года назад

      Hi Aislan, you can see how to add a circle in #2 video of this leaflet series. ruclips.net/video/OYjFR_CGV8o/видео.html
      The slider must return a value that will then take the radius parameter of the circle.

  • @danyaviation2626
    @danyaviation2626 4 года назад

    Can you make a tutorial about How to show lines when you Click on a marker?

    • @sabafatima1719
      @sabafatima1719 Год назад

      so, you want to popup a message when clicked on a marker? use this code as reference:
      var geojsonFeature = {
      "type": "Feature",
      "properties": {"name": "Coors Field", "amenity": "Baseball Stadium", "popupContent": "This is where the Rockies play!"},
      "geometry": {"type": "Point","coordinates": [-104.99404, 39.75621]}
      };
      L.geoJSON(geojsonFeature, {
      onEachFeature: function (feature, layer) {layer.bindPopup(feature.properties.popupContent);}
      }).addTo(map);

    • @danyaviation2626
      @danyaviation2626 Год назад

      @@sabafatima1719 thanks but I made the feature, I made a route map where you click on markers and then routes would be shown

  • @mathiashomberger3996
    @mathiashomberger3996 4 года назад

    how can i change the colour of the lines?

    • @sabafatima1719
      @sabafatima1719 Год назад +1

      by styling it, here's a reference code:
      var myLines =
      {
      "type": "Feature",
      "geometry": {"type": "LineString","coordinates": [[51.50, -0.08], [51.51, -0.06],[51.52, -0.04]]}
      };
      var myStyle = { "color": "#FF0000", "weight": 9 };
      L.geoJSON(myLines, {style: myStyle}).addTo(map);