
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
react-leaflet-magnifying-glass
Advanced tools
React wrapper of Leaflet.MagnifyingGlass. Add a 'magnifying glass' effect to a Leaflet map, able to display a portion of the map in a different zoom (and actually display different content).
React wrapper of Leaflet.MagnifyingGlass for react-leaflet.
This plugin allows you to add a "magnifying glass" effect to a Leaflet map, able to display a portion of the map in a different zoom (and actually display different content).
Tested with Leaflet 1.4.0 and React-Leaflet 1.9.1, React-Leaflet 2.2.0
Version | Demo |
---|---|
react-leaflet@1.9.1 | CodePen |
react-leaflet@2.x | CodePen |
npm install --save react-leaflet-magnifying-glass
v1
import { Map, TileLayer } from 'react-leaflet';
import MagnifyingGlassControl from 'react-leaflet-magnifying-glass';
const options = {
position: 'topleft',
radius: 100,
zoomOffset: 3
};
<Map center={[2.935403, 101.448205]} zoom={10}>
<TileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
/>
<MagnifyingGlassControl {...options} />
</Map>
v2
import { Map, TileLayer, withLeaflet } from 'react-leaflet';
import MagnifyingGlassControlDefault from 'react-leaflet-magnifying-glass';
// wrap `MagnifyingGlassControl` component with `withLeaflet` HOC
const MagnifyingGlassControl = withLeaflet(MagnifyingGlassControlDefault);
const options = {
position: 'topleft',
radius: 100,
zoomOffset: 3
};
<Map center={[2.935403, 101.448205]} zoom={10}>
<TileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
/>
<MagnifyingGlassControl {...options} />
</Map>
Option | Type | Default | Description |
---|---|---|---|
position | string | topleft | Magnifier control position. One of (topleft ,topright ,bottomleft ,bottomright ). |
radius | Integer | 100 | The radius of the magnifying glass, in pixels. |
zoomOffset | Integer | 3 | The zoom level offset between the main map zoom and the magnifying glass. |
fixedZoom | Integer | -1 | If different than -1 , defines a fixed zoom level to always use in the magnifying glass, ignoring the main map zoom and the zoomOffet value. |
Leaflet.markercluster
layerCredits goes to bbecquet and all the contributors for the original work.
MIT License
2.0.0 (2019-02-05)
FAQs
React wrapper of Leaflet.MagnifyingGlass. Add a 'magnifying glass' effect to a Leaflet map, able to display a portion of the map in a different zoom (and actually display different content).
The npm package react-leaflet-magnifying-glass receives a total of 12 weekly downloads. As such, react-leaflet-magnifying-glass popularity was classified as not popular.
We found that react-leaflet-magnifying-glass demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.