0.2.14 • Published 1 year ago

react-native-leaflet-ts-beta v0.2.14

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

React Native Leaflet TS

Please show your support by adding a star! :)

react-native-leaflet-ts is a library with Typescript support that let's you to render a Leaflet in a WebView.

NOTE! Library is new, this will be updated & more stuff will be added.

npm npm npm

Installation

Npm

npm install react-native-leaflet-ts

Yarn

yarn add react-native-leaflet-ts

Usage

import Leaflet from 'react-native-leaflet-ts';

Usage with props

import Leaflet, { Markers, TileOptions } from 'react-native-leaflet-ts';

Release log

API Reference

Leaflet

ParameterTypeDefaultStatusDescription
mapsrc: string, tileOptions: TileOptionsRequired
zoomnumber0Optional
maxZoomnumberOptional
minZoomnumberOptional
flyTo{ latLng: number[], zoom number }OptionalFlies to a specific marker
startInLoadingStatebooleantrueOptionalMap starts in loading state
backgroundColorstringtransparentOptionalBackgroundColor of map
onMessagefunctionOptional(event: any) => void;
onErrorfunctionOptional(event: any) => void
onLoadStartfunctionOptionalWhen webview loads starts loading

map

ParameterTypeDefaultStatusDescription
srcstringRequiredSource to "{z}/{x}/{-y}.png" tile url
optionsTileOptionsOptional

TileOptions

https://leafletjs.com/reference.html#tilelayer

ParameterTypeDefaultStatusDescription
tileSizenumber256OptionalWidth and height of the tails in the grid
opacitynumber1OptionalOpacity of the map
updateWhenIdlebooleanOptionalLoad new tiles only when panning ends
updateWhenZoomingbooleantrueOptionalZoom animation
updateIntervalnumber200OptionalTile update speed
zIndexnumber1OptionalzIndex of tile
bounds[number[]]Optional
noWrapbooleanfalseOptionalIf map should be repeated
panestringOptional
classNamestringOptional
keepBuffernumber2Optional
detectRetinabooleanfalseOptional

Markers

ParameterTypeDefaultStatusDescription
latLngnumber[]RequiredPosition of the marker on the map
iconstringOptionalexample: "src/assets/pin.png"
iconSize{ width: number, height: number}Optionalsize of icon
disabledbooleanfalseOptionalWeather it's clickable or not
titlestring""OptionalText in textbox after clicking on a marker

Examples

const markerList: Markers[] = [
  {
    latLng: [-38.31571580761326, -23.735463483398522],
    iconSize: {
      width: 25,
      height: 25,
    },
    icon: './src/assets/mapPin.png',
    title: 'Title 1',
    disabled: true,
  },
  {
    latLng: [-58.31571543253336, -43.535453281293517],
    iconSize: {
      width: 25,
      height: 25,
    },
    title: 'Title 2',
  },
];
<Leaflet
  map={{
    src: source,
    tileOptions: {
      noWrap: true,
    },
  }}
  minZoom={1}
  zoom={2}
  maxZoom={6}
  flyTo={{
    latLng: [-38.31571580761326, -23.735463483398522],
    zoom: 5,
  }}
  markers={markerList}
  backgroundColor="green"
/>

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Links

We App GitHub

Help / Info

If you need any of the other Leaflet properties just let me know and I'll add them in. Send me a mail at patrick@weapp.se.

0.2.14

1 year ago

0.2.13

2 years ago

0.2.12

2 years ago

0.2.11

2 years ago

0.2.10

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago