Socket
Book a DemoInstallSign in
Socket

react-native-maps

Package Overview
Dependencies
Maintainers
14
Versions
391
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-maps

React Native Mapview component for iOS + Android

Source
npmnpm
Version
0.31.1
Version published
Weekly downloads
413K
0.37%
Maintainers
14
Weekly downloads
 
Created

What is react-native-maps?

The react-native-maps package provides a set of components for displaying and interacting with maps in React Native applications. It supports both Google Maps and Apple Maps, and offers a variety of features such as markers, polygons, and custom map styles.

What are react-native-maps's main functionalities?

Displaying a Map

This feature allows you to display a map in your React Native application. The initialRegion prop sets the initial region displayed by the map.

import MapView from 'react-native-maps';

const MyMap = () => (
  <MapView
    style={{ flex: 1 }}
    initialRegion={{
      latitude: 37.78825,
      longitude: -122.4324,
      latitudeDelta: 0.0922,
      longitudeDelta: 0.0421,
    }}
  />
);

Adding Markers

This feature allows you to add markers to the map. Markers can have coordinates, titles, and descriptions.

import MapView, { Marker } from 'react-native-maps';

const MyMapWithMarkers = () => (
  <MapView
    style={{ flex: 1 }}
    initialRegion={{
      latitude: 37.78825,
      longitude: -122.4324,
      latitudeDelta: 0.0922,
      longitudeDelta: 0.0421,
    }}
  >
    <Marker
      coordinate={{
        latitude: 37.78825,
        longitude: -122.4324,
      }}
      title={'My Marker'}
      description={'This is a description of the marker'}
    />
  </MapView>
);

Drawing Polygons

This feature allows you to draw polygons on the map. Polygons are defined by an array of coordinates and can have custom fill and stroke colors.

import MapView, { Polygon } from 'react-native-maps';

const MyMapWithPolygon = () => (
  <MapView
    style={{ flex: 1 }}
    initialRegion={{
      latitude: 37.78825,
      longitude: -122.4324,
      latitudeDelta: 0.0922,
      longitudeDelta: 0.0421,
    }}
  >
    <Polygon
      coordinates={[
        { latitude: 37.8025259, longitude: -122.4351431 },
        { latitude: 37.7896386, longitude: -122.421646 },
        { latitude: 37.7665248, longitude: -122.4161628 },
        { latitude: 37.7734153, longitude: -122.4577787 },
        { latitude: 37.7948605, longitude: -122.4596065 },
      ]}
      fillColor={'rgba(100, 200, 200, 0.3)'}
      strokeColor={'rgba(0,0,0,0.5)'}
      strokeWidth={2}
    />
  </MapView>
);

Custom Map Styles

This feature allows you to apply custom styles to the map. The customMapStyle prop takes an array of style objects that define the appearance of various map elements.

import MapView from 'react-native-maps';

const MyStyledMap = () => (
  <MapView
    style={{ flex: 1 }}
    customMapStyle={[
      {
        elementType: 'geometry',
        stylers: [
          {
            color: '#242f3e'
          }
        ]
      },
      {
        elementType: 'labels.text.stroke',
        stylers: [
          {
            color: '#242f3e'
          }
        ]
      },
      {
        elementType: 'labels.text.fill',
        stylers: [
          {
            color: '#746855'
          }
        ]
      }
    ]}
    initialRegion={{
      latitude: 37.78825,
      longitude: -122.4324,
      latitudeDelta: 0.0922,
      longitudeDelta: 0.0421,
    }}
  />
);

Other packages similar to react-native-maps

Keywords

react

FAQs

Package last updated on 30 Apr 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