1.2.1 • Published 1 year ago

turkey-map-react v1.2.1

Weekly downloads
6
License
MIT
Repository
github
Last release
1 year ago

Interactive Turkey Map React Component

An out-of-the-box city map of Turkey.

Installation

npm install turkey-map-react

or

yarn add turkey-map-react

Usage

Importing (ES6)

import TurkeyMap from 'turkey-map-react';

Basic usage with defaults

<TurkeyMap />

Handling events

On click example:

<TurkeyMap onClick={ ({ plateNumber, name }) => console.log(plateNumber + " - " + name + " is just clicked!") } />

On mouse over example:

<TurkeyMap 
    hoverable={true}
    onHover={ ({ plateNumber, name }) => console.log("Cursor is over on " + plateNumber + " - " + name + "!") } 
/>

City component wrapping

const renderCity = (cityComponent, cityData) => ( 
  <Tooltip title={cityData.name} key={cityData.id}> 
      {cityComponent} 
  </Tooltip>
);

<TurkeyMap cityWrapper={renderCity} />

This is generally used for Antd style Tooltip.

"child" parameter is the city DOM.

Custom Data

<TurkeyMap data={this.state.apiData}/>

If custom SVG paths and/or city metadata is needed to be rendered, it can be provided through data property.

data property has to be in type of following:

CityType[] 

in other words :

{ id: string, plateNumber: number, name: string, path: string }[]

API

Types

TypeDescription
CityType{ id: string, plateNumber: number, name: string, path: string }
ViewBoxType{ top: number, left: number, width: number, height: number }
CustomStyleType{ idleColor: string, hoverColor: string }

props

PropertyDescriptionTypeDefaultSince
viewBoxPosition and dimension information of the map (svg) layoutViewBoxType{ top: 0, left: 80, width: 1050, height: 585 }1.0.0
visibleDefines the visibility of the componentbooleantrue1.0.0
hoverableEnables onHover event availabilitybooleantrue1.0.0
showTooltipDisplays default tooltip if set to truebooleanfalse1.1.0
tooltipTextSets custom text to default tooltipstringCity Name1.1.0
customStyleStylizing the component.CustomStyleType[]{ idleColor: #444, hoverColor: #dc3522 }1.0.0
dataAllows for providing custom SVG paths and metadata.CityType[]Built-in data1.0.0
cityWrapperCity DOMs are wrapped by provided component.( cityComponent: JSX.Element, city : CityType ) => JSX.ElementUnwrapped city1.0.0
onHoverEvent when a city hovered on the map.( city : CityType ) => void-1.0.0
onClickEvent when a city clicked on the map( city : CityType ) => void-1.0.0

Styling

Colors of the city can be overwritten with setting customStyle property.

Example:

<TurkeyMap customStyle={{ idleColor: "#444", hoverColor: "#dc3522" }} />

Default tooltip can be styled through predefined html IDs.

#svg-turkiye-haritasi-container-tooltip is the ID for tooltip DOM. While #svg-turkiye-haritasi-container is the ID for container (parent) DOM.

Example:

#svg-turkiye-haritasi-container > #svg-turkiye-haritasi-container-tooltip {
  background-color: rgba(54, 0, 99, 0.479);
}

Licensing

This project is released under a MIT License.

Versioning

Versioning scheme defined as in the pattern of "majorVersion.minorVersion.bugfixVersion"

LevelDescription
majorVersionThis indicates that the version introduces breaking changes those possibly not backward compatible features.
minorVersionThis indicates that the version introduces small changes those are backward compatible with fine fitting for existing uses.
bugfixVersionThis indicates that the version solves some problems those popped out in the current major or minor versions.

Contributing

To contribute to this project please just open a pull request with a comprehensive description.


Credits

This project has been derivated from dnomak's svg-turkiye-haritasi project.

1.1.6

1 year ago

1.2.1

1 year ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago