0.0.2 • Published 4 years ago

react-native-map-clustering-custom-font v0.0.2

Weekly downloads
9
License
MIT
Repository
github
Last release
4 years ago

React Native Map Clustering

React Native module that handles map clustering for you.

this is a form from https://github.com/venits/react-native-map-clustering , using it till PR accepted.

use clusterFontFamily to customize your cluster font style

Works with Expo and react-native-cli 🚀

This repo is proudly sponsored by:

Demo

Demo

Spiral

Converting same locations in spiral view (done automatically)

Spiral

Installation

// clustering module
npm install react-native-map-clustering-custom-font --save

// and only if you haven't installed it before
npm install react-native-maps --save

Full example

Example of how to use clustering.

import React from "react";
import MapView from "react-native-map-clustering-custom-font";
import { Marker } from "react-native-maps";

const INITIAL_REGION = {
  latitude: 52.5,
  longitude: 19.2,
  latitudeDelta: 8.5,
  longitudeDelta: 8.5
};

const App = () => (
  <MapView initialRegion={INITIAL_REGION} style={{ flex: 1 }}>
    <Marker coordinate={{ latitude: 52.4, longitude: 18.7 }} />
    <Marker coordinate={{ latitude: 52.1, longitude: 18.4 }} />
    <Marker coordinate={{ latitude: 52.6, longitude: 18.3 }} />
    <Marker coordinate={{ latitude: 51.6, longitude: 18.0 }} />
    <Marker coordinate={{ latitude: 53.1, longitude: 18.8 }} />
    <Marker coordinate={{ latitude: 52.9, longitude: 19.4 }} />
    <Marker coordinate={{ latitude: 52.2, longitude: 21 }} />
    <Marker coordinate={{ latitude: 52.4, longitude: 21 }} />
    <Marker coordinate={{ latitude: 51.8, longitude: 20 }} />
    <Marker coordinate={{ latitude: 51.8, longitude: 20 }} />
    <Marker coordinate={{ latitude: 51.8, longitude: 20 }} />
    <Marker coordinate={{ latitude: 51.8, longitude: 20 }} />
    <Marker coordinate={{ latitude: 51.8, longitude: 20 }} />
  </MapView>
);

export default App;

Props

NameTypeDefaultNote
clusterColorString#00B386Background color of cluster.
clusterTextColorString#FFFFFFColor of text in cluster.
onClusterPress(cluster, markers)Function() => {}Allows you to control cluster on click event. Function returns information about cluster and its markers.
widthNumberwindow widthmap's width.
heightNumberwindow heightmap's height.
radiusNumberwindow.width * 6%SuperCluster radius.
extentNumber512SuperCluster extent.
minZoomNumber1SuperCluster minZoom.
maxZoomNumber20SuperCluster maxZoom.
preserveClusterPressBehaviorBoolfalseIf set to true, after clicking on cluster it will not be zoomed.
edgePaddingObject{ top: 50, left: 50, bottom: 50, right: 50 }Edge padding for react-native-maps's fitToCoordinates method, called in onClusterPress for fitting to pressed cluster children.
animationEnabledBooltrueAnimate imploding/exploding of clusters' markers and clusters size change. Works only on iOS.
layoutAnimationConfLayoutAnimationConfigLayoutAnimation.Presets.springLayoutAnimation.Presets.springCustom Layout animation configuration object for clusters animation during implode / explode Works only on iOS.
onRegionChangeComplete(region, markers)Function() => {}Called when map's region changes. In return you get current region and markers data.
mapRef(ref)Function() => {}Return reference to react-native-maps MapView component.
clusteringEnabledBooltrueSet true to enable and false to disable clustering.
renderClusterFunctionundefinedEnables you to render custom cluster with custom styles and logic.
spiderLineColorString#FF0000Enables you to set color of spider line which joins spiral location with center location.

Support

Feel free to create issues and pull requests. I will try to provide as much support as possible over Github. In case of questions or problems, contact me at: t.przybyl@venits.com

Happy Coding 💖