├── package.json ├── .gitignore ├── MapboxMap.jsx ├── LICENSE └── README.md /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-mapboxmap", 3 | "version": "0.0.3", 4 | "description": "A Mapbox component for React.js", 5 | "author": "Ale ", 6 | "license": "MIT", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/iamale/MapboxMap.git" 10 | }, 11 | "main": "MapboxMap.js", 12 | "scripts": { 13 | "build": "babel MapboxMap.jsx > MapboxMap.js", 14 | "prepublish": "npm run build" 15 | }, 16 | "dependencies": {}, 17 | "devDependencies": { 18 | "babel": "^5.8.21" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io 2 | 3 | ### Node ### 4 | # Logs 5 | logs 6 | *.log 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | 13 | # Directory for instrumented libs generated by jscoverage/JSCover 14 | lib-cov 15 | 16 | # Coverage directory used by tools like istanbul 17 | coverage 18 | 19 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 20 | .grunt 21 | 22 | # node-waf configuration 23 | .lock-wscript 24 | 25 | # Compiled binary addons (http://nodejs.org/api/addons.html) 26 | build/Release 27 | 28 | # Dependency directory 29 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 30 | node_modules 31 | 32 | # Compiled js 33 | MapboxMap.js 34 | -------------------------------------------------------------------------------- /MapboxMap.jsx: -------------------------------------------------------------------------------- 1 | var React = require('react'); 2 | var ReactDOM = require('react-dom') 3 | // Assuming Mapbox/Leaflet is already exposed as `L` 4 | 5 | var MapboxMap = React.createClass({ 6 | componentDidMount: function(argument) { 7 | var props = this.props; 8 | 9 | var mapId = props.mapId || props.src || "mapbox.streets"; 10 | 11 | var options = {}; 12 | var ownProps = ['mapId', 'onMapCreated']; 13 | for (var k in props) { 14 | if (props.hasOwnProperty(k) && ownProps.indexOf(k) === -1) { 15 | options[k] = props[k]; 16 | } 17 | } 18 | 19 | var map = L.mapbox.map(ReactDOM.findDOMNode(this), mapId, options); 20 | 21 | if (this.props.onMapCreated) { 22 | this.props.onMapCreated(map, L); 23 | } 24 | }, 25 | 26 | render: function() { 27 | var mapStyle = { 28 | width: '100%', 29 | height: '100%' 30 | }; 31 | 32 | return ( 33 |
34 | ); 35 | } 36 | }); 37 | 38 | module.exports = MapboxMap; 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2015 Alexander Pushkov 2 | 3 | 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: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MapboxMap 2 | ========== 3 | 4 | **Notice**: this never was a full-feature library, merely a layer on top of Mapbox JS SDK. For a better, more full fledged solution, try [react-leaflet](https://github.com/PaulLeCam/react-leaflet) (in conjunction with the Mapbox [Maps API](https://www.mapbox.com/api-documentation/#maps) in our case). 5 | 6 | ``` 7 | npm install react-mapboxmap 8 | ``` 9 | 10 | ```js 11 | var React = require('react'), 12 | MapboxMap = require('react-mapboxmap'); 13 | 14 | var Master = React.createClass({ 15 | render: function() { 16 | return ( 17 |
18 | 23 |
24 | ); 25 | }, 26 | _onMapCreated: function(map, L) { 27 | var marker = new L.Marker(new L.LatLng(59.907433, 30.299848)); 28 | map.addLayer(marker); 29 | } 30 | }); 31 | ``` 32 | 33 | Attributes 34 | ----------- 35 | 36 | * `mapId` or `src` -- either a map id (`examples.map-foo`), a comma-separated list of ids, a URL to TileJSON (`https://api.tiles.mapbox.com/v3/examples.map-0l53fhk2.json`) or a TileJSON object 37 | 38 | * `onMapCreated(map, L)` -- a callback for furter customization. Params: 39 | 40 | - `map` -- the map object 41 | - `L` -- the Leaflet.js instance used to create the map (Mapbox.js included) 42 | 43 | License 44 | -------- 45 | 46 | MIT 47 | --------------------------------------------------------------------------------