New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-apple-mapkit-directions

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-apple-mapkit-directions

React Native wrapper for Apple MapKit Directions

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-apple-mapkit-directions npm version Downloads

React Native wrapper for Apple MapKit Directions. You can get distance, expectedTravelTime, name, advisoryNotices or coordinates. Work ONLY for IOS!

Installation

npm install react-native-apple-mapkit-directions

or

yarn add react-native-apple-mapkit-directions

then install pod

cd ios && pod install

Usage

import {
  getAppleMapKitDirections,
  MapKitTransit,
} from 'react-native-apple-mapkit-directions';

// ...
const origin = {
  latitude: 55.751244,
  longitude: 37.618423,
};
const destination = {
  latitude: 59.9375,
  longitude: 30.308611,
};
const transitType = MapKitTransit.AUTOMOBILE;
const points = await getAppleMapKitDirections(origin, destination, transitType);

You can use it with react-native-maps

import * as React from 'react';

import { StyleSheet } from 'react-native';
import MapView, { LatLng, Polyline } from 'react-native-maps';
import {
  getAppleMapKitDirections,
  MapKitTransit,
} from 'react-native-apple-mapkit-directions';

export default function App() {
  const styles = StyleSheet.create({
    map: {
      ...StyleSheet.absoluteFillObject,
    },
  });
  const origin = {
    latitude: 55.751244,
    longitude: 37.618423,
  };
  const destination = {
    latitude: 59.9375,
    longitude: 30.308611,
  };
  const transitType = MapKitTransit.AUTOMOBILE;
  const [state, setState] = React.useState<LatLng[]>();
  React.useEffect(() => {
    const getPoints = async () => {
      if (Platform.OS === 'ios') {
        try {
          const points = await getAppleMapKitDirections(
            origin,
            destination,
            transitType
          );
          setState(points.coordinates);
        } catch (error) {
          console.log('error', error);
        }
      }
    };
    getPoints();
  }, []);

  return (
    <MapView style={styles.map}>
      {state && <Polyline coordinates={state} />}
    </MapView>
  );
}

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

Keywords

FAQs

Package last updated on 30 Jan 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc