1.2.8 • Published 4 months ago

react-apple-mapkit v1.2.8

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

MapKit React Integration

A comprehensive library to seamlessly integrate Apple MapKit JS with React. This library provides TypeScript support and rich configuration options for maps, markers, and annotations.


Table of Contents

  1. Installation
  2. Getting Started
  3. Configuration
  4. Event Handling
  5. Examples
  6. API Reference
  7. License

1. Installation

Install the package using npm or yarn:

npm install react-apple-mapkit

or

yarn add react-apple-mapkit

2. Getting Started

Initialization

Before using the map, you need to initialize MapKit with an authentication token.

import React from 'react';
import Map from 'react-apple-mapkit';

const App = () => {
  return (
    <Map token="YOUR_MAPKIT_JS_TOKEN">
      <h1>Apple MapKit Integration</h1>
    </Map>
  );
};

export default App;

3. Configuration

3.1 Map Configuration

PropTypeDefaultDescription
tokenstringRequiredMapKit JS API token.
mapTypestandard, mutedStandard, hybrid, satellitestandardMap type.
distancesadaptive, metric, imperialadaptiveDistance measurement system.
showsCompassFeatureVisibilityadaptiveCompass visibility.
showsScaleFeatureVisibilityhiddenScale visibility.
cameraBoundaryCoordinateRegionnullRestrict map camera boundary.
cameraZoomRange{ min: number, max: number }{ min: 0, max: Infinity }Define zoom limits for the camera.
paddingTop, paddingRight, paddingBottom, paddingLeftnumber0Map padding.
onRegionChangeStart(region: CoordinateRegion) => voidundefinedEvent triggered at region change start.
onRegionChangeEnd(region: CoordinateRegion) => voidundefinedEvent triggered at region change end.

3.2 Marker Configuration

PropTypeDefaultDescription
latitudenumberRequiredMarker latitude.
longitudenumberRequiredMarker longitude.
titlestring""Marker title.
subtitlestring""Marker subtitle.
colorstring#fb0000Marker color.
glyphColorstring#ffffffGlyph text color.
collisionMode'Rectangle' or 'Circle' or nullnullCollision detection mode.
subtitleVisibilityFeatureVisibilityadaptiveSubtitle visibility.
titleVisibilityFeatureVisibilityadaptiveTitle visibility.

3.3 Annotation Configuration

PropTypeDefaultDescription
latitudenumberRequiredAnnotation latitude.
longitudenumberRequiredAnnotation longitude.
titlestring""Annotation title.
subtitlestring""Annotation subtitle.
collisionMode'Rectangle' or 'Circle' or nullnullCollision detection mode.
calloutElementReactNodeundefinedCustom callout content.
calloutOffsetX, calloutOffsetYnumber0Callout offset adjustments.

4. Event Handling

Events can be easily attached to map and markers.

Map Events

EventDescription
onLoadTriggered when the map is loaded.
onRegionChangeStartTriggered at the start of region change.
onRegionChangeEndTriggered at the end of region change.
onSingleTapTriggered on single tap.

Marker Events

EventDescription
onSelectTriggered when a marker is selected.
onDeselectTriggered when a marker is deselected.
onDragStartTriggered when dragging starts.
onDragEndTriggered when dragging ends.

5. Examples

Basic Map

import React from 'react';
import Map from 'react-apple-mapkit';

const App = () => (
  <Map token="YOUR_MAPKIT_JS_TOKEN">
    <h2>My Map</h2>
  </Map>
);

export default App;

Map with Marker

import React from 'react';
import Map from 'react-apple-mapkit';
import Marker from 'react-apple-mapkit/Marker';

const App = () => (
  <Map token="YOUR_MAPKIT_JS_TOKEN">
    <Marker latitude={37.7749} longitude={-122.4194} title="San Francisco" />
  </Map>
);

export default App;

6. API Reference

Coordinate

Represents a point on the Earth’s surface.

interface Coordinate {
  latitude: number;
  longitude: number;
}

CoordinateRegion

Represents a geographic region.

interface CoordinateRegion {
  centerLatitude: number;
  centerLongitude: number;
  latitudeDelta: number;
  longitudeDelta: number;
}

7. License

This project is licensed under the MIT License. See the LICENSE file for details.


For more detailed information, visit the official documentation. 🎉

1.2.8

4 months ago

1.2.7

4 months ago

1.2.6

4 months ago

1.2.4

4 months ago

1.2.3

4 months ago

1.2.2

4 months ago

1.2.1

4 months ago

1.2.0

4 months ago

1.1.9

4 months ago

1.1.8

4 months ago

1.1.7

4 months ago

1.1.6

4 months ago

1.1.5

4 months ago

1.1.4

4 months ago

1.1.3

4 months ago

1.1.2

4 months ago

1.1.1

4 months ago

1.1.0

4 months ago

1.0.9

4 months ago

1.0.8

4 months ago

1.0.7

4 months ago

1.0.6

4 months ago

1.0.5

4 months ago

1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago