Socket
Socket
Sign inDemoInstall

@react-leaflet/core

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-leaflet/core

React Leaflet core


Version published
Weekly downloads
286K
increased by0.62%
Maintainers
1
Weekly downloads
 
Created

What is @react-leaflet/core?

@react-leaflet/core is a core library for integrating Leaflet maps with React. It provides a set of hooks and components that allow developers to create interactive maps with ease, leveraging the power of React's declarative approach.

What are @react-leaflet/core's main functionalities?

Map Container

This feature allows you to create a map container and add a tile layer to it. The MapContainer component initializes the map, and the TileLayer component adds the map tiles from OpenStreetMap.

import { MapContainer, TileLayer } from '@react-leaflet/core';

function MyMap() {
  return (
    <MapContainer center={[51.505, -0.09]} zoom={13} style={{ height: '100vh', width: '100%' }}>
      <TileLayer
        url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
        attribution="&copy; <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors"
      />
    </MapContainer>
  );
}

Markers

This feature allows you to add markers to the map. The Marker component places a marker at the specified position, and the Popup component displays a popup when the marker is clicked.

import { MapContainer, TileLayer, Marker, Popup } from '@react-leaflet/core';

function MyMap() {
  return (
    <MapContainer center={[51.505, -0.09]} zoom={13} style={{ height: '100vh', width: '100%' }}>
      <TileLayer
        url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
        attribution="&copy; <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors"
      />
      <Marker position={[51.505, -0.09]}>
        <Popup>
          A pretty CSS3 popup. <br /> Easily customizable.
        </Popup>
      </Marker>
    </MapContainer>
  );
}

Polylines

This feature allows you to draw polylines on the map. The Polyline component takes an array of latitude and longitude pairs and draws a line connecting them.

import { MapContainer, TileLayer, Polyline } from '@react-leaflet/core';

function MyMap() {
  const polyline = [
    [51.505, -0.09],
    [51.51, -0.1],
    [51.51, -0.12]
  ];

  return (
    <MapContainer center={[51.505, -0.09]} zoom={13} style={{ height: '100vh', width: '100%' }}>
      <TileLayer
        url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
        attribution="&copy; <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors"
      />
      <Polyline positions={polyline} />
    </MapContainer>
  );
}

Other packages similar to @react-leaflet/core

Keywords

FAQs

Package last updated on 24 Sep 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc