Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wemap/expo-livemap

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wemap/expo-livemap

Expose a Livemap component and methods to interact with it

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-91.59%
Maintainers
0
Weekly downloads
 
Created
Source

@wemap/expo-livemap

A custom WebView component for Expo applications that exposes a Livemap component and methods to interact with it.

Installation

npm install @wemap/expo-livemap

Usage

Basic Usage

import React from 'react';
import { View } from 'react-native';
import { LiveMap } from '@wemap/expo-livemap';

function App() {
  const handleCustomMessage = (event) => {
    console.log('Received message from LiveMap:', event);
  };

  return (
    <View style={{ flex: 1 }}>
      <LiveMap
        source={{ uri: 'https://livemap.getwemap.com' }}
        onCustomMessage={handleCustomMessage}
      />
    </View>
  );
}

Advanced Usage with Ref

import React, { useRef } from 'react';
import { View, Button } from 'react-native';
import { LiveMap, LiveMapRef } from '@wemap/expo-livemap';

function App() {
  const mapRef = useRef<LiveMapRef>(null);

  const handleCustomMessage = (event) => {
    console.log('Received message from LiveMap:', event);
  };

  const sendMessageToMap = () => {
    mapRef.current?.postCustomMessage('Hello from React Native!');
  };

  return (
    <View style={{ flex: 1 }}>
      <LiveMap
        ref={mapRef}
        source={{ uri: 'https://livemap.getwemap.com' }}
        onCustomMessage={handleCustomMessage}
      />
      <Button 
        title="Send Message to LiveMap" 
        onPress={sendMessageToMap} 
      />
    </View>
  );
}

WebView JavaScript Interface

Inside your web content, you can send messages to React Native using the injected postCustomMessage function:

// Send message from LiveMap to React Native
window.postCustomMessage({
  type: 'mapEvent',
  data: 'Map is ready!'
});

API Reference

Props

The component accepts all standard React Native WebView props plus:

onCustomMessage: (event: any) => void Callback function that handles messages sent from the LiveMap

Ref Methods

postCustomMessage(message: string): Sends a message to the LiveMap reload(): Reloads the LiveMap

TypeScript Support

The package includes TypeScript definitions. For TypeScript projects, you can import types:

import { LiveMapProps, LiveMapRef } from '@wemap/expo-livemap';

Requirements

  • Expo SDK 51 or higher
  • React Native WebView 11 or higher

License

MIT

Author

Simon Milleto simon@getwemap.com

Keywords

FAQs

Package last updated on 13 Nov 2024

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