npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rn-map-carousel

v0.2.3

Published

map library

Downloads

4

Readme

rn-map-carousel

Una librería de React Native para mostrar e interactuar con mapas ,marcadores y un carrousel.

Instalación

Usando npm

npm install rn-map-carousel

Usando yarn

yarn add rn-map-carousel

Configuración de Google Maps

Android

Agrega tu clave de API de Google Maps en tu archivo AndroidManifest.xml:

<application
    android:networkSecurityConfig="@xml/network_security_config"
    android:usesCleartextTraffic="true">
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="TU_CLAVE_DE_API_DE_GOOGLE_MAPS" />
    ...
</application>

Actualizar gradle-wrapper.properties

Asegúrate de que tu archivo gradle-wrapper.properties contenga la siguiente configuración:

distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip

iOS

Agrega tu clave de API de Google Maps en tu archivo AppDelegate:

#import <GoogleMaps/GoogleMaps.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [GMSServices provideAPIKey:@"TU_CLAVE_DE_API_DE_GOOGLE_MAPS"];
    // ...
}
@end

Asegúrate de que tu Podfile especifica un mínimo de iOS 13 (obviarlo si ya esta especificado en el proyecto):

platform :ios, '13.0'

Si estás utilizando CocoaPods versión 1.15.0 o mayor

Añade la siguiente línea a tu Gemfile para usar la versión 1.14.0 de CocoaPods:

gem 'cocoapods', '1.14.0'

Luego, instala la versión especificada de CocoaPods:

bundle install

Instala las dependencias de CocoaPods:

cd ios
bundle exec pod install

Uso

Aquí tienes un ejemplo de cómo usar la biblioteca del mapa con un componente de carrusel (tambien tiene una carpeta de example con el uso):

interface Coordenadas {
latitud: number;
longitud: number;
}

interface Beneficio {
id:string;
titulo: string;
descripcion: string;
imagen: string;
promocion: string;
direccion: string;
coordenadas: Coordenadas;
}

export default function App() {
const [beneficios, setBeneficios] = useState<Beneficio[]>([]);
const [loading, setLoading] = useState<boolean>(true);
const [error, setError] = useState<string | null>(null);
const carouselRef = useRef<any>(null);

useEffect(() => {
    const unregisterListener = registerMarkerSelectListener((event) => {
    console.log('Marker seleccionado', event);
    
    });
    
    const fetchData = async () => {
    try {
        const responseData = await fetch('https://demo1012858.mockable.io/benefits');
        if (!responseData.ok) {
        throw new Error('Sucedio un error');
        }
        const response = await responseData.json();
        setBeneficios(response.data);
        for (const benefit of response.data) {
            console.log('Agregando el beneficio', benefit)
            addMarker(benefit)
        }

    } catch (error) {
        setError((error as {message:string}).message);
    } finally {
        setLoading(false);
    }
    };
    fetchData();

    return () => {
    unregisterListener();
    }
}, []);

const addMarker = async(benefit:Beneficio) => {
    try {
    const res = await MapLibrary.addMarker(
                            benefit.coordenadas.latitud, 
                            benefit.coordenadas.longitud, 
                            benefit.titulo, 
                            benefit.id);
                            
    } catch (error) {
    console.error('RN Error:',error)
    }
}

return (
    <View style={styles.bg}>
    <SafeAreaView style={styles.container}>
        <MapView style={styles.map} />
        <Carousel items={beneficios} />
    </SafeAreaView>
    </View>
);
}

const styles = StyleSheet.create({
bg:{
    flex:1,
},
container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
},
box: {
    width: 60,
    height: 60,
    marginVertical: 20,
},
map: {
    height:'100%',
    width:'100%'
},
});

Componentes

MapView

El componente MapView muestra el mapa y permite la interacción con él.

Propiedades

style (opcional): El estilo a aplicar a la vista del mapa.

Carousel

El componente Carousel muestra un carrusel horizontal de elementos.

Propiedades

items (requerido): Un array de elementos a mostrar en el carrusel. Cada elemento debe tener una propiedad titulo y imagen.

Licencia

MIT