1.4.4 • Published 6 months ago

map-trix v1.4.4

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

Map Trix : Google Maps Interface

npm

Description

This module provides an easy to use interface that allows to load and use Google Maps API.

Install

Available via npm as the package Map Trix.

npm install map-trix

Documentation and Usage

Load the lib and create an instance

import { createMapTrix } from 'map-trix'

// Google Maps lib options
const options = { 
    key: 'Your Google API Key',
    language: 'en', 
    version: 'weekly', 
    libraries: ["places"]
    /* TODO : to be completed */ 
}

/**
 * Load the lib and create an instance
 * @param {string} API_KEY : Your Google API Key @deprecated since version 1.4.4 please use options.key
 * @param {object} options : { center: { lat: 0, lng: 0 }, zoom: 5 ... }
 * @param {object} config : { enableBounds: false }
 * @returns : MapTrix instance
 */ 
const mapTrix = await createMapTrix(API_KEY, options)

mapTrix.init('#YourMapElSelector')

Add marker

// Add marker without infoWindow
const point1 = {
    latitude: 48.85840, 
    longitude: 2.29448
}
mapTrix.addMarker(point)

// Add marker with infoWindow
const point2 = {
    latitude: 48.87574, 
    longitude: 2.29517, 
    content: 'infoWindow content'
}
mapTrix.addMarker(point2, true)

// Center map on loaded markers
mapTrix.boundsMarkers()

Create route between two points

/**
 * @param {String|{latitude, longitude}} origin
 * @param {String|{latitude, longitude}} destination
 */
mapTrix.traceDirection(point1, point2).then( successResponse => /* Your code here */ )

Load current location

import Utils from './utils/utils'


/**
 * Load current user position
 * @param {enableHighAccuracy = true, timeout = 5000, maximumAge = 0}
 */
Utils.getCurrentPosition().then( response => {
    // Your code here...
    // for example
    mapTrix.addMarker({
        latitude: response.coords.latitude, 
        longitude: response.coords.longitude, 
        content: 'My position'}, 
        true
    )
})
1.4.4

6 months ago

1.4.3

6 months ago

1.4.2

6 months ago

1.4.1

6 months ago

1.4.0

6 months ago

1.3.6

11 months ago

1.3.5

12 months ago

1.3.4

12 months ago

1.3.3

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago