Determine if a point reside inside a leaflet polygon

Use the Ray Casting algorithm for checking if a point (marker) lies inside of a polygon: function isMarkerInsidePolygon(marker, poly) { var polyPoints = poly.getLatLngs(); var x = marker.getLatLng().lat, y = marker.getLatLng().lng; var inside = false; for (var i = 0, j = polyPoints.length – 1; i < polyPoints.length; j = i++) { var xi = … Read more

React-Leaflet marker files not found

Try to do this 🙂 React leaflet for some reason do not include images and you will need to reset default icons image. Below is some working example, I hope it will solve your issue. You also can add icons from one of public link https://cdnjs.com/libraries/Leaflet.awesome-markers import React, { Component } from ‘react’; import L … Read more

Leaflet Marker not found production env

This is a known bug in Leaflet, the root issue is that Leaflet’s icon image location is been wrongly referenced during bundling. You can verify that this is your issue, buy validating this parameter (in run time): L.Icon.Default.prototype._getIconUrl(). The correct value should be <some_directory>/leaflet/dist/images/. However if this bug is happening to you, it’s value is: … Read more

Good way to combine React and Leaflet

You don’t need to manage uniqueness, i.e. “UID”, yourself. Instead, you can use getDOMNode to access the component’s real node. Leaflet’s API supports either a string selector or an HTMLElement instance. Leaflet is managing rendering, so the map should not live on state. Only store data in state that affects React’s rendering of the DOM … Read more