0.1.4 • Published 5 years ago

here-maps-react-hardforked v0.1.4

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

here-maps-react NPM npm.io npm.io

React components library for HERE Maps

Easily integrate HERE Maps into your app with a set of React components.

Full TypeScript support!

Tree shakeable!

Install

npm install --save here-maps-react

Usage

Map

import React from 'react'
import HEREMap from 'here-maps-react'

class Map extends React.Component {
  render() {
    return (
      <HEREMap
        appId="my_app_id"
        appCode="my_app_code"
        center={{ lat: -12.0464, lng: -77.0428 }}
        zoom={12}
      />
    )
  }
}

Props

PropertyTypeOptionalDescription
appIdstringfalseThe App Id you got after registering to HERE
appCodestringfalseThe App Code you got after registering to HERE
centerobjecttrueInitial map coordinates { lat, lng }
zoomnumbertrueInitial zoom level
animateCenterbooleantrueAnimate center prop change
animateZoombooleantrueAnimate zoom level change
hidpibooleantrueWhether to use high quality map tiles or not
interactivebooleantrueWhether to use static or interactive maps
securebooleantrueIf true, here-maps-react will load the HTTPS HERE api
setLayerobjecttrueAn object that can be used to set the map style { layer, mapType }. You can find available configurations HERE

Marker

import React from 'react'
import HEREMap, { Marker } from 'here-maps-react'

class Map extends React.Component {
  render() {
    return (
      <HEREMap
        appId="my_app_id"
        appCode="my_app_code"
        center={{ lat: -12.0464, lng: -77.0428 }}
        zoom={12}
      >
        <Marker
          lat={-12.1199408}
          lng={-77.037241}
          draggable
          onDragEnd={e => {...}}
        />
      </HEREMap>
    )
  }
}

Props

PropertyTypeOptionalDescription
bitmapstringtrueAn image to be used as a marker
latnumberfalseThe latitude to place the marker
lngnumberfalseThe longitude to place the marker
childrenJSX.ElementtrueYou can use markup to put elements on the map
draggablebooleantrueFlag to enable drag events on the marker
onDragStart(event) => voidtrueFunction to listen to HERE's dragstart event
onDrag(event) => voidtrueFunction to listen to HERE's drag event
onDragEnd(event) => voidtrueFunction to listen to HERE's dragend event

RouteLine

import React from 'react'
import HEREMap, { Marker, RouteLine } from 'here-maps-react'

class Map extends React.Component {
  render() {
    return (
      <HEREMap
        appId="my_app_id"
        appCode="my_app_code"
        center={{ lat: -12.0464, lng: -77.0428 }}
        zoom={12}
      >
        <Marker lat={-12.1199408} lng={-77.037241} />
        <Marker lat={-12.1261171} lng={-77.02060549999999} />
        <RouteLine
          shape={this.state.shape}
          strokeColor="#48dad0"
          lineWidth={4}
        />
      </HEREMap>
    )
  }
}

Props

PropertyTypeOptionalDescription
shapestring[]falseAn array of latitudes and longitudes obtained using the HERE Routing API
strokeColornumbertrueAn optional (HEX, RGB, HSL...) color
lineWidthnumbertrueA number representing the width of the route line

This library is based on the original react-here-maps, updated to conform to React StrictMode, as well as, adding new components.

License

MIT © ordazgustavo