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

@akaribrahim/here-maps-drawing

v0.0.20

Published

Here Maps JS API drawing tool

Downloads

6

Readme

Status License


📝 Table of Contents

🧐 About

We can do simple operations using Here Maps Js API but it doesn't provide any drawing tools. The purpose of this library is to be able to draw shapes like polygons on Here Maps.

🏁 Installation

npm install @akaribrahim/here-maps-drawing

🎈 Usage

<HereMapContainer apiKey={hereApiKey}>
  {(mapObjects: MapObjects): JSX.Element => <PolygonDraw map={mapObjects.map} />}
</HereMapContainer>

🎈 Docs

KNOWN ISSUE: Components are having trouble working with StrictMode that comes with React 18 or later. It will run in the production environment, but you must disable StrictMode in the development environment.

HereMapContainer

With the onSuccess method, we can take the map, platform, ui, behavior objects and perform all the operations written in the HereMaps document.

| | Description | Default Value | isRequired | | ------------------: | :---------------------------------------------------: | :-------------------------------------: | :--------: | | apiKey | HereMaps Api Key | null | Yes | | center | Center coordinates to be given when the map is loaded | {lat:41.03115 , lng: 29.00214} | No | | zoom | Zoom level when map is loaded | 9 | No | | useEvents | Use Events | true | No | | useUi | Use Ui | true | No | | containerStyles | Style object of map container | {height: 500, width: '100%'} | No | | resizeOnWidthChange | Resize the map on window.resize event | true | No | | mapLanguage | Map Language | 'en-US' | No | | onSuccess | Callback function returning map objects | ({map, platform, behavior, ui}) => {} | No |

PolygonDraw

With the onSuccess method, we can take the map, platform, ui, behavior objects and perform all the operations written in the HereMaps document.

| | Description | Default Value | isRequired | | -----------------------: | :---------------------------------------------------------------------------------: | :---------------------------------------------: | :--------: | | map | Core Map Object | null | Yes | | color | Instead of messing with the whole style from scratch, just changing the color (HEX) | null | No | | drawingStyles | Styles for each step, see DrawingStyles section for more details | See DrawingStyles | No | | useShortcuts | Use keyboard shortcut to help drawing | true | No | | shortcuts | shortcut keys | See ShortcutKeys | No | | onShortcutCallback | Callback that returns information when using a shortcut | ({keyCode, char}) => {} | No | | onSuccess | Callback function, on polygon drawing finish | (finalPolygon, mainGroup) => {} | No | | onPutCornerPoint | Callback function, on each corner point | ({ currentPointCount }) => {} | No | | onEdit(Coming Soon) | Callback function, on polygon edited | (finalPolygon, polygonIndex, mainGroup) => {} | No | | isResizable(Coming Soon) | Final polygon resizable or not | true | No |

DrawingStyles

Default Values of drawingStyles as follows.

Icons must be in the form that H.map.Icon() will accept

drawingStyles: {
    firstIcon: rectangleSvg('#185CF7').trim(),
    icon: rectangleSvg().trim(),
    polylineStylesOnDraw: { // The line drawn around the polygon at the drawing stage
       lineWidth: 3,
       strokeColor: '#185CF7',
       lineJoin: 'round',
    },
    polygonStylesOnDraw: { // Polygon at the drawing stage
       lineWidth: 0,
       fillColor: 'rgba(24, 92, 247, 0.2)',
    },
    movingPolylineStyles: { // The line following mouse movements
       lineWidth: 3,
       strokeColor: '#185CF7',
       lineJoin: 'round',
       lineDash: [2],
       lineDashOffset: 1,
    },
    finalPolygonStyles: { // Polygon created in the final
       lineWidth: 3,
       strokeColor: '#185CF7',
       lineJoin: 'round',
       fillColor: 'rgba(24, 92, 247, 0.2)',
    },
}

ShortcutKeys

You can create shortcuts for three different events. Events only work during the polygon drawing phase

It can be customized by changing the keyCode and char values in the format given below.

Undo => Deletes the last point

Merge => Completes the polygon by connecting it with the first point

Cancel => Deletes the polygon in the drawing phase.

{
    undo: {
       keyCode: 85,
       char: 'U',
    },
    merge: {
       keyCode: 77,
       char: 'M',
    },
    cancel: {
       keyCode: 27,
       char: 'ESC',
    },
}

✍️ Authors