<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hossam Ayman</title>
    <description>The latest articles on DEV Community by Hossam Ayman (@hossam43).</description>
    <link>https://dev.to/hossam43</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1002780%2Fbbf3a923-3630-480e-9e07-9b7f3d9d875f.jpeg</url>
      <title>DEV Community: Hossam Ayman</title>
      <link>https://dev.to/hossam43</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hossam43"/>
    <language>en</language>
    <item>
      <title>"Error with Leaflet Map - Unable to display tiles on the map"</title>
      <dc:creator>Hossam Ayman</dc:creator>
      <pubDate>Thu, 02 Feb 2023 08:17:39 +0000</pubDate>
      <link>https://dev.to/hossam43/error-with-leaflet-map-unable-to-display-tiles-on-the-map-4f28</link>
      <guid>https://dev.to/hossam43/error-with-leaflet-map-unable-to-display-tiles-on-the-map-4f28</guid>
      <description>&lt;p&gt;I am encountering an issue when drawing polygons, point, and line features on a map using the Leaflet.js library. &lt;/p&gt;

&lt;p&gt;The polygon is correctly displayed on the map, but the moment I try to draw a &lt;strong&gt;point ** or **line&lt;/strong&gt;, they *&lt;em&gt;disappear *&lt;/em&gt; immediately after releasing the mouse click. I need assistance to correct this issue and make the drawing of points and lines on the map functional.&lt;/p&gt;

&lt;p&gt;`var map = L.map("leaflet-map", {&lt;br&gt;
  center: [37.7749, -122.4194],&lt;br&gt;
  zoom: 8,&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;let osm = L.tileLayer("&lt;a href="https://tile.openstreetmap.org/%7Bz%7D/%7Bx%7D/%7By%7D.png?%7Bfoo%7D"&gt;https://tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}&lt;/a&gt;", {&lt;br&gt;
  foo: "bar",&lt;br&gt;
  attribution:&lt;br&gt;
    '© &lt;a href="https://www.openstreetmap.org/copyright"&gt;OpenStreetMap&lt;/a&gt; contributors',&lt;br&gt;
});&lt;br&gt;
osm.addTo(map);&lt;/p&gt;

&lt;p&gt;var CyclOSM = L.tileLayer(&lt;br&gt;
  "https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png",&lt;br&gt;
  {&lt;br&gt;
    attribution:&lt;br&gt;
      '&lt;a href="https://github.com/cyclosm/cyclosm-cartocss-style/releases" title="CyclOSM - Open Bicycle render"&gt;CyclOSM&lt;/a&gt; | Map data: © &lt;a href="https://www.openstreetmap.org/copyright"&gt;OpenStreetMap&lt;/a&gt; contributors',&lt;br&gt;
  }&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;CyclOSM.addTo(map);&lt;/p&gt;

&lt;p&gt;var Esri_WorldImagery = L.tileLayer(&lt;br&gt;
  "&lt;a href="https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D"&gt;https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}&lt;/a&gt;",&lt;br&gt;
  {&lt;br&gt;
    attribution:&lt;br&gt;
      "Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community",&lt;br&gt;
  }&lt;br&gt;
).addTo(map);&lt;/p&gt;

&lt;p&gt;let baseLayers = {&lt;br&gt;
  "Esri World Imagery": Esri_WorldImagery,&lt;br&gt;
  "Open Street Map": osm,&lt;br&gt;
  "Cycl OSM": CyclOSM,&lt;br&gt;
};&lt;br&gt;
//Creates three feature groups for points, polygons, and lines on the map&lt;br&gt;
var pointLayer = L.featureGroup().addTo(map);&lt;br&gt;
var polygonsLayer = L.featureGroup().addTo(map);&lt;br&gt;
var lineLayer = L.featureGroup().addTo(map);&lt;br&gt;
var polygon;&lt;br&gt;
var point;&lt;br&gt;
var line;&lt;br&gt;
var allLayers = L.featureGroup([pointLayer, polygonsLayer, lineLayer]).addTo(&lt;br&gt;
  map&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;//Add new shapes drawn on the map to the appropriate feature group&lt;br&gt;
map.on("draw:created", function (e) {&lt;br&gt;
  var type = e.layerType,&lt;br&gt;
    layer = e.layer;&lt;br&gt;
  if (type === "point") {&lt;br&gt;
    point = layer;&lt;br&gt;
    point.addTo(pointLayer);&lt;br&gt;
    point.addTo(map);&lt;br&gt;
  } else if (type === "polygon") {&lt;br&gt;
    polygon = layer;&lt;br&gt;
    polygon.addTo(polygonsLayer);&lt;br&gt;
    polygonsLayer.addTo(map);&lt;br&gt;
  } else if (type === "line") {&lt;br&gt;
    line = layer;&lt;br&gt;
    line.addTo(lineLayer);&lt;br&gt;
    lineLayer.addTo(map);&lt;br&gt;
  }&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;var drawControl = new L.Control.Draw({&lt;br&gt;
  draw: {&lt;br&gt;
    marker: true,&lt;br&gt;
    polyline: true,&lt;br&gt;
    polygon: true,&lt;br&gt;
    rectangle: true,&lt;br&gt;
    circle: true,&lt;br&gt;
  },&lt;br&gt;
}).addTo(map);`&lt;/p&gt;

</description>
      <category>leaflet</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
