{"id":6726,"date":"2023-01-21T21:27:09","date_gmt":"2023-01-21T21:27:09","guid":{"rendered":"https:\/\/www.garysieling.com\/blog\/?p=6726"},"modified":"2023-01-21T21:27:09","modified_gmt":"2023-01-21T21:27:09","slug":"react-leaflet-geojson-component-based-popup","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/react-leaflet-geojson-component-based-popup\/","title":{"rendered":"React Leaflet GeoJSON Component-based Popup"},"content":{"rendered":"\n<p>In the ticket below, someone asks about how to make a pop-up tooltip for GeoJson in React-leaflet:<\/p>\n\n\n\n<figure class=\"wp-block-embed\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/github.com\/PaulLeCam\/react-leaflet\/issues\/787\n<\/div><\/figure>\n\n\n\n<p>A complete solution is below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;GeoJSON\n  key={dataKey + (cacheBuster++)}\n  filter={(segment, index) => {\n    \/\/ implement this to enable\/disable specific tiles in the layer\n    return true;\n  }}\n onEachFeature={(feature, leafletLayer) => {\n    const popupOptions = {\n      minWidth: 100,\n      maxWidth: 250,\n      className: \"popup-classname\"\n    };\n      \n    leafletLayer.bindPopup(()=>{\n      return '&lt;b>tooltip&lt;\/b>\n    }, popupOptions);\n  }}\n  style={\n    (reference) => {\n       return {\n         color: 'blue'\n       }\n    }\n  }\n  data={geojsonData} \/><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In the ticket below, someone asks about how to make a pop-up tooltip for GeoJson in React-leaflet: A complete solution is below:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4,6],"tags":[633,630,632,357,455,631],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/6726"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=6726"}],"version-history":[{"count":1,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/6726\/revisions"}],"predecessor-version":[{"id":6727,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/6726\/revisions\/6727"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=6726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=6726"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=6726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}