├── .babelrc
├── .eslintignore
├── .eslintrc
├── .flowconfig
├── .gitignore
├── .npmignore
├── .nvmrc
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE.md
├── README.md
├── example
├── index.html
├── index.js
└── webpack.config.js
├── lib
└── MarkerLayer.js
├── package.json
├── screenshot.jpg
└── src
├── MarkerLayer.js
└── __tests__
└── MarkerLayer.test.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "plugins": [
3 | "babel-plugin-transform-do-expressions",
4 | "babel-plugin-transform-function-bind",
5 | "babel-plugin-transform-class-constructor-call",
6 | ["babel-plugin-transform-class-properties", { "loose": true }],
7 | "babel-plugin-transform-decorators",
8 | "babel-plugin-transform-export-extensions",
9 | "babel-plugin-syntax-trailing-function-commas",
10 | "babel-plugin-transform-object-rest-spread",
11 | "babel-plugin-transform-async-to-generator",
12 | "babel-plugin-transform-exponentiation-operator",
13 |
14 | "babel-plugin-transform-react-jsx",
15 | "babel-plugin-transform-flow-strip-types",
16 | "babel-plugin-syntax-flow",
17 | "babel-plugin-syntax-jsx",
18 | "babel-plugin-transform-react-display-name",
19 |
20 | ["babel-plugin-transform-es2015-template-literals", { "loose": true }],
21 | "babel-plugin-transform-es2015-literals",
22 | "babel-plugin-transform-es2015-function-name",
23 | "babel-plugin-transform-es2015-arrow-functions",
24 | "babel-plugin-transform-es2015-block-scoped-functions",
25 | ["babel-plugin-transform-es2015-classes", { "loose": true }],
26 | "babel-plugin-transform-es2015-object-super",
27 | "babel-plugin-transform-es2015-shorthand-properties",
28 | ["babel-plugin-transform-es2015-computed-properties", { "loose": true }],
29 | ["babel-plugin-transform-es2015-for-of", { "loose": true }],
30 | "babel-plugin-transform-es2015-sticky-regex",
31 | "babel-plugin-transform-es2015-unicode-regex",
32 | ["babel-plugin-transform-es2015-spread", { "loose": true }],
33 | "babel-plugin-transform-es2015-parameters",
34 | ["babel-plugin-transform-es2015-destructuring", { "loose": true }],
35 | "babel-plugin-transform-es2015-block-scoping",
36 | "babel-plugin-transform-es2015-typeof-symbol",
37 | ["babel-plugin-transform-es2015-modules-commonjs", { "loose": true }],
38 | "babel-plugin-transform-regenerator"
39 | ]
40 | }
41 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules/**
2 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint-config-airbnb",
3 | "parser": "babel-eslint",
4 | "env": {
5 | "browser": true,
6 | "mocha": true,
7 | "node": true
8 | },
9 | "globals": {
10 | "__data": true,
11 | "expect": true,
12 | "ga": true,
13 | "Intercom": true,
14 | "spy": true,
15 | "sinon": true,
16 | "Raven": true,
17 | "Highcharts": true
18 | },
19 | "rules": {
20 | "comma-dangle": 0,
21 | "no-wrap-func": 0,
22 | "spaced-comment": 0,
23 | "eqeqeq": [2, "smart"],
24 |
25 | // Portal uses some camelcase
26 | "camelcase": 1,
27 |
28 | // used for creating new Immutable Lists and Maps
29 | "new-cap": [1, {"capIsNewExceptions": ["Immutable"]}],
30 |
31 | // Sometimes short variable names are okay
32 | "id-length": 0,
33 |
34 | // Doesn't play nice with chai's assertions
35 | "no-unused-expressions": 0,
36 |
37 | "react/jsx-uses-react": 2,
38 | "react/jsx-uses-vars": 2,
39 | "react/react-in-jsx-scope": 2,
40 | "react/jsx-no-duplicate-props": 2,
41 |
42 |
43 | // Discourages microcomponentization
44 | "react/no-multi-comp": 0,
45 |
46 | //Temporarirly disabled due to a possible bug in babel-eslint (todomvc example)
47 | "block-scoped-var": 0,
48 | // Temporarily disabled for test/* until babel/babel-eslint#33 is resolved
49 | "padded-blocks": 0,
50 |
51 | },
52 | "plugins": [
53 | "react",
54 | "lean-imports"
55 | ]
56 | }
57 |
--------------------------------------------------------------------------------
/.flowconfig:
--------------------------------------------------------------------------------
1 | [ignore]
2 | .*/node_modules/babel-cli/.*
3 | .*/node_modules/babel-generator/.*
4 | .*/node_modules/babel-helper-builder-binary-assignment-operator-visitor/.*
5 | .*/node_modules/babel-helper-explode-assignable-expression/.*
6 | .*/node_modules/babel-helper-remap-async-to-generator/.*
7 | .*/node_modules/babel-helper-regex/.*
8 | .*/node_modules/babel-plugin-transform-regenerator/.*
9 | .*/node_modules/babel-template/.*
10 | .*/node_modules/babel-types/.*
11 | .*/node_modules/jsxhint/.*
12 | .*/node_modules/fbjs/.*
13 | .*/node_modules/flow-bin/.*
14 | .*/node_modules/flux/.*
15 | .*/node_modules/node-sass/.*
16 | .*/node_modules/phantomjs/.*
17 | .*/node_modules/react-styleguidist/.*
18 | .*/node_modules/config-chain/.*
19 | .*/node_modules/findup/.*
20 |
21 |
22 | [include]
23 |
24 | [libs]
25 |
26 | [options]
27 | esproposal.class_instance_fields=enable
28 | suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe
29 | esproposal.class_static_fields=enable
30 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Compiled binary addons (http://nodejs.org/api/addons.html)
17 | build/Release
18 | build
19 |
20 | # Dependency directory
21 | # Commenting this out is preferred by some people, see
22 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
23 | node_modules
24 | bower_components
25 |
26 | # Users Environment Variables
27 | .lock-wscript
28 | .sass-cache
29 |
30 | .idea/
31 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .babelrc
2 | .gitignore
3 | .npmignore
4 | .nvmrc
5 | screenshot.jpg
6 |
--------------------------------------------------------------------------------
/.nvmrc:
--------------------------------------------------------------------------------
1 | 4.3.0
2 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # 0.1.3 Release
2 |
3 | - Only fit bounds on update when data or position extractors change
4 |
5 | # 0.1.2 Release
6 |
7 | - Improve performance by implementing `shouldComponentUpdate` with `react-pure-render/function`
8 |
9 | # 0.1.1 Release
10 |
11 | - fix casing issue with `isNumber` import
12 |
13 | # 0.1.0 Release
14 |
15 | - Handle fitBounds better when bad data is present
16 | - added `fitBoundsOnUpdate` parameter to fit the markers on the map when they change
17 |
18 | # 0.0.6 Release
19 |
20 | - Actually build the 0.0.5 changes
21 |
22 | # 0.0.5 Release
23 |
24 | - Marker objects that return bad data for location are no longer rendered and are ignored when repositioning
25 |
26 | # 0.0.2 Release
27 |
28 | - Fix an issue with unmounting layer
29 |
30 | # 0.0.1 Release
31 |
32 | - Initial implementation of package
33 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Things you can do to contribute include:
4 |
5 | 1. Report a bug by [opening an issue](https://github.com/OpenGov/react-leaflet-marker-layer/issues/new)
6 | 2. Suggest a change by [opening an issue](https://www.github.com/OpenGov/react-leaflet-marker-layer/issues/new)
7 | 3. Fork the repository and fix [an open issue](https://github.com/OpenGov/react-leaflet-marker-layer/issues)
8 |
9 | ### Technology
10 |
11 | `react-leaflet-marker-layer` is a custom layer for the `react-leaflet` package. This package is a convenient wrapper around Leaflet, a mapping library, for React. The source code is written with ES6/ES2015 syntax as well as [FlowType](http://flowtype.org) type annotations.
12 |
13 | ### Install dependencies
14 |
15 | 1. Install Node via [nodejs.org](http://nodejs.org)
16 | 2. After cloning the repository, run `npm install` in the root of the project
17 |
18 | This project is developed with Node version 4.3.0 and NPM 3.3.10.
19 |
20 | ### Contributing via Github
21 |
22 | The entire project can be found [on Github](https://github.com/OpenGov/react-leaflet-marker-layer). We use the [fork and pull model](https://help.github.com/articles/using-pull-requests/) to process contributions.
23 |
24 | #### Fork the Repository
25 |
26 | Before contributing, you'll need to fork the repository:
27 |
28 | 1. Fork the repository so you have your own copy (`your-username/react-leaflet-marker-layer`)
29 | 2. Clone the repo locally with `git clone https://github.com/your-username/react-leaflet-marker-layer`
30 | 3. Move into the cloned repo: `cd react-leaflet-marker-layer`
31 | 4. Install the project's dependencies: `npm install`
32 |
33 | You should also add `OpenGov/react-leaflet-marker-layer` as a remote at this point. We generally call this remote branch 'upstream':
34 |
35 | ```
36 | git remote add upstream https://github.com/OpenGov/react-leaflet-marker-layer
37 | ```
38 |
39 | #### Development
40 |
41 | You can work with a live, hot-reloading example of the component by running:
42 |
43 | ```bash
44 | npm run example
45 | ```
46 |
47 | And then visiting [localhost:8000](http://localhost:8000).
48 |
49 | As you make changes, please describe them in `CHANGELOG.md`.
50 |
51 | #### Submitting a Pull Request
52 |
53 | Before submitting a Pull Request please ensure you have completed the following tasks:
54 |
55 | 1. Describe your changes in `CHANGELOG.md`
56 | 2. Make sure your copy is up to date: `git pull upstream master`
57 | 3. Ensure that all tests pass, tests for the component can be found in `lib/__tests__/MarkerLayer.test.js`, you can run these tests with `npm test`
58 | 3. Run `npm run compile`, to compile your changes to the exported `/lib` code.
59 | 4. Bump the version in `package.json` as appropriate, see `Versioning` in the section below.
60 | 4. Commit your changes
61 | 5. Push your changes to your fork: `your-username/react-leaflet-marker-layer`
62 | 6. Open a pull request from your fork to the `upstream` fork (`OpenGov/react-leaflet-marker-layer`)
63 |
64 | ## Versioning
65 |
66 | This project follows Semantic Versioning.This means that version numbers are basically formatted like `MAJOR.MINOR.PATCH`.
67 |
68 | #### Major
69 |
70 | Breaking changes are signified with a new **first** number. For example, moving from 1.0.0 to 2.0.0 implies breaking changes.
71 |
72 | #### Minor
73 |
74 | New components, new helper classes, or substantial visual changes to existing components and patterns are *minor releases*. These are signified by the second number changing. So from 1.1.2 to 1.2.0 there are minor changes.
75 |
76 | #### Patches
77 |
78 | The final number signifies patches such as fixing a pattern or component in a certain browser, or fixing an existing bug. Small changes to the documentation site and the tooling around the Calcite-Web library are also considered patches.
79 |
80 | ## Developer's Certificate of Origin 1.1
81 |
82 | By making a contribution to this project, I certify that:
83 |
84 | * (a) The contribution was created in whole or in part by me and I
85 | have the right to submit it under the open source license
86 | indicated in the file; or
87 |
88 | * (b) The contribution is based upon previous work that, to the best
89 | of my knowledge, is covered under an appropriate open source
90 | license and I have the right under that license to submit that
91 | work with modifications, whether created in whole or in part
92 | by me, under the same open source license (unless I am
93 | permitted to submit under a different license), as indicated
94 | in the file; or
95 |
96 | * (c) The contribution was provided directly to me by some other
97 | person who certified (a), (b) or (c) and I have not modified
98 | it.
99 |
100 | * (d) I understand and agree that this project and the contribution
101 | are public and that a record of the contribution (including all
102 | personal information I submit with it, including my sign-off) is
103 | maintained indefinitely and may be redistributed consistent with
104 | this project or the open source license(s) involved.
105 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | Copyright (c) 2016 OpenGov, Inc.
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 |
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 |
8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-leaflet-marker-layer
2 |
3 | `react-leaflet-marker-layer` provides a simple `` component for plotting React components as markers in a `react-leaflet` map.
4 |
5 | 
6 |
7 | ## Usage
8 |
9 | ```js
10 | import React from 'react';
11 | import { render } from 'react-dom';
12 | import { Map, Marker, Popup, TileLayer } from 'react-leaflet';
13 | import MarkerLayer from '../src/MarkerLayer';
14 |
15 | const position = { lng: -122.673447, lat: 45.522558 };
16 | const markers = [
17 | {
18 | position: { lng: -122.67344700000, lat: 45.522558100000 },
19 | text: 'Voodoo Doughnut',
20 | },
21 | {
22 | position: { lng: -122.67814460000, lat: 45.5225512000000 },
23 | text: 'Bailey\'s Taproom',
24 | },
25 | {
26 | position: { lng: -122.67535700000002, lat: 45.5192743000000 },
27 | text: 'Barista'
28 | },
29 | {
30 | position: { lng: -122.65596570000001, lat: 45.5199148000001 },
31 | text: 'Base Camp Brewing'
32 | }
33 | ];
34 |
35 | class ExampleMarkerComponent extends React.Component {
36 |
37 | render() {
38 | const style = {
39 | border: 'solid 1px lightblue',
40 | backgroundColor: '#333333',
41 | borderRadius: '50%',
42 | marginTop: '-12px',
43 | marginLeft: '-12px',
44 | width: '24px',
45 | height: '24px'
46 | };
47 |
48 | return (
49 |