🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More →
Socket
Book a DemoSign in
Socket

react-native-cluster-map-optimus

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-cluster-map-optimus

React Native MapView clustering component for iOS + Android

latest
Source
npmnpm
Version
1.0.10
Version published
Maintainers
1
Created
Source

react-native-cluster-map

license Version npm Email

React Native MapView clustering component for iOS + Android

Made by CODEMPIRE

Examples

Zoom inZoom out
Example zoom outExample zoom in
Cluster ExpandNested Cluster Expand
Example cluster expandExample nested cluster expand

Installation

npm install --save react-native-cluster-map

Usage

import { Marker } from 'react-native-maps';
import { ClusterMap } from 'react-native-cluster-map';

<ClusterMap
  region={{
    latitude: 37.78825,
    longitude: -122.4324,
    latitudeDelta: 0.0922,
    longitudeDelta: 0.0421,
  }}
>
  <Marker coordinate={{ latitude: 37.78725, longitude: -122.434 }} />
  <Marker coordinate={{ latitude: 37.789, longitude: -122.431 }} />
  <Marker coordinate={{ latitude: 37.78825, longitude: -122.4324 }} />
</ClusterMap>;

Custom Cluster Marker

You can customize cluster marker with renderClusterMarker prop

MyMap.jsx

import { Marker } from "react-native-maps";
import { MyCluster } from "./MyCluster";

// ...

renderCustomClusterMarker = (count) => <MyCluster count={count} />

render () {
  const { markers, region } = this.state;
  return (
    <ClusterMap
      renderClusterMarker={this.renderCustomClusterMarker}
      region={region}
    >
      {markers.map((marker) => (
          <Marker {...marker} />
      ))}
    <ClusterMap>
  )
}

MyCluster.jsx

import * as React from 'react';
import { View, Text, StyleSheet } from 'react-native';

export const MyCluster = (props) => {
  const { count } = props;
  return (
    <View style={styles}>
      <Text>{count}</Text>
    </View>
  );
};

const styles = StyleSheet.create({
  width: 50,
  height: 50,
  borderRadius: 25,
  backgroundColor: 'red',
  justifyContent: 'center',
  alignItems: 'center',
});

Result

Custom Marker Example

Props

PropsTypeDefault valueNote
superClusterOptionsOptions{ radius: 16, maxZoom: 15, minZoom: 1, nodeSize: 16 }SuperCluster lib options
isClusterExpandClickbooleantrueEnables cluster zoom on click
regionRegionrequiredGoogle Map Region
priorityMarkerReactNodenullMarker which will be outside of clusters
renderClusterMarker(object):ReactNodeundefinedReturns cluster marker component
clusterMarkerPropsobjectundefinedAdditional ClusterMarker props
provider'google' or null'google'Map provider. If null will use the platform default one (Google Maps for Android and MapKit for iOS)
styleStylePropabsoluteFillObjectStyling for MapView

Children Props

PropsTypeDefaultNote
isOutsideClusterbooleanfalsePrevent child from clusterization. Required for not a Marker children (e.g. Polygon, Polyline, Circle)

Also contains react-native-maps <MapView /> Props

Events

Event NameReturnsNotes
onClusterClick({ clusterId: number, coordinate : LatLng }, children: Marker[])Callback that is called when the user pressed on the cluster marker
onZoomChangevoidCallback that is called with updated map zoom in number

Also contains react-native-maps <MapView /> Events

Keywords

android

FAQs

Package last updated on 11 Aug 2021

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