1596289080
React wrapper for mapboxgl-js API.
Made with by MeilleursAgents
import React from 'react';
import MapboxMap from 'react-mapbox-wrapper';
export default function SimpleMap() {
return (
<div style={{ height: 400, width: 400 }}>
<MapboxMap
accessToken="<your acess token here>"
coordinates={{ lat: 48.872198, lng: 2.3366308 }}
/>
</div>
);
}
SimpleMap.displayName = 'SimpleMap';
See examples folder for more example.
Read carefully the getting started section of Mapbox GL API.
If you use Webpack, you should add the following parameter in order to properly build your app.
module: {
noParse: /(mapbox-gl)\.js$/,
}
react-mapbox-wrapper
import the corresponding CSS stylesheet from Javascript, you don’t have to do it.
React Component that render a Mapbox Map. Extra props are directly passed to the Map constructor. Following props are handled by wrapper for updating or handling behavior in the React philosophy.
Wrapper is CSS flex-ready for width but you have to set a height for having visible Mapbox.
Props | Type | Default | Description |
---|---|---|---|
accessToken | String | required | Mapbox Access Token (find it here) |
coordinates | Object | required | Coordinates of the map center |
According to the LngLatLike model | |||
className | string | '' |
className added to map’s wrapper. Your should provide a height in order to render the map (default at 0) |
children | Node | null |
Rendered children, typically a Marker and/or Circle |
minZoom | number | undefined |
The minimum zoom level of the map (0-24). |
maxZoom | number | undefined |
The maximum zoom level of the map (0-24). |
zoom | number | 15 |
The viewport zoom |
onChange | func | undefined |
Callback function called on every viewport change (moveend , zoomend ) |
Callback receive param with the following shape
{ zoom: 15, coordinates: { lng: 3.4, lat: 1.2 } }
|
| onClick | func | undefined
| Callback function called on map’s click |
| onLoad | func | undefined
| Callback function called on map’s load with current Mapbox instance param |
| onZoomStart | func | undefined
| Callback function called on map’s zoomstart |
| onZoomEnd | func | undefined
| Callback function called on map’s zoomend with a debounce of 300ms in order to avoid too many render()
call |
| renderNotSupported | func | Simple message | Callback function called when browser does not support mapbox-gl |
| mapboxStyle | String | | Mapbox style layer |
| withCompass | bool | false
| Show compass Navigation Control |
| withFullscreen | bool | false
| Show Fullscreen Control |
| withZoom | bool | false
| Show zoom Navigation Control |
| fullscreenControlPosition | string | top-right
| Set Fullscreen Control position |
| navigationControlPosition | string | bottom-right
| Set Navigation Control position |
React Component that render a Marker. Extra props are directly passed to the Marker constructor
Props | Type | Default | Description |
---|---|---|---|
children | Node | null |
Marker HTML DOM, default marker will be used if not provided |
coordinates | Object | required | Coordinates of the marker |
According to the LngLatLike model | |||
draggable | bool | false |
Allow user to drag’n’drop Marker |
getRef | func | Callback function called with marker’s ref (useful for calling #moveToTop() function) |
|
map | Object | required | Mapbox Map where marker will be added (can be obtained with MapboxMap#onLoad props fn) |
onDragEnd | func | Callback function called on marker’s dragend | |
onMouseOut | func | Callback function called on marker or popup mouseOut | |
onMouseOver | func | Callback function called on marker or popup mouseOver | |
popup | Node | Popup attached to the marker, displayed on click to marker | |
popupAnchor | string | bottom |
Popup anchor param |
popupCloseButton | bool | false |
Popup closeButton param |
popupOffset | number | Popup offset param | |
popupOnOver | bool | false |
Trigger popup show on mouse over (only available if children are provided, default marker cannot be bind) |
React Component that render a Circle. Extra props are directly passed to the Marker constructor
Props | Type | Default | Description |
---|---|---|---|
coordinates | Object | required | Coordinates of the marker |
According to the LngLatLike model | |||
id | string | required | Identifier of circle, used to name the underlying layer |
map | Object | required | Mapbox Map where marker will be added (can be obtained with MapboxMap#onLoad props fn) |
onClick | func | Callback function called on circle’s click | |
paint | Object | Paint option of the layer | |
radius | number | required | Radius of circle, in kilometers |
unit | string | kilometers |
Unit of the radius. values can be : kilometers , meters , miles , feet |
We provide some helpers for interacting with Mapbox Map object, all in Helpers
import.
import { Helpers } from react-mapbox-wrapper;
Helpers.convertRadiusUnit(580, 'meters');
// > { radius: 0.58, unit: 'kilometers' }
Helpers.getCircleData({ lat: 48.868526, lng: 2.3434886 }, 800, 'meters')
// > Coordinates for drawing a circle with a 800meters radius at given coordinates
Helpers.coordinatesAreEqual({ lat: 48.868526, lng: 2.3434886 }, [2.3434886, 48.868526]);
// > Check if given coordinates are equal, even in different format
Helpers.newBounds(coordinatesSouthWest, coordinatesNorthEast);
// > Create a new LngLatBounds from Mapbox library
Helpers.newBound(coordinates);
// > Create a new LngLatLike from Mapbox library
Helpers.drawGeoJSON(map, 'foodTruck', data, { 'fill-opacity': 0.2 }, undefined, 'fill');
// > Draw a geoJSON with given data and type. Can be used to also update geoJSON if layer already exist
Helpers.removeGeoJSON(map, 'foodTruck');
// > Remove the layer previously added with #addGeoJSON method
npm install && npm run peers # install both dependencies and peers
You can use npm link
while developing new features on this repo for use in targeted repository.
npm link
You can use our pre-commit
hook for ensuring consistent format and linting before committing by running command:
./tools/install_hooks.sh
Author: MeilleursAgents
Live Demo: https://meilleursagents.github.io/react-mapbox-wrapper/
GitHub: https://github.com/MeilleursAgents/react-mapbox-wrapper
#javascript #react #reactjs
1605523740
This article will walk you through the concepts you would need to know to step into the world of widely used ReactJS.
If you are here, you must be already a web developer with an understanding of javascript. You could be using just plain vanilla Javascript or could be a developer using libraries and frameworks already.
Let’s jump in and refresh some concepts to understand what React has in for us.
Libraries are primarily to help you get things done in an efficient way. jQuery was there to avoid complicated code and made it easy to do common functionalities like selecting items on the web page, creating elements, and appending them to either body or another element on the page.
As a web developer, we know there are a million ways to build a web page or a web application. Out of these million ways, there are certain ways that are scalable and can be supported at a large scale, so larger enterprises with varying developers with a wide range of skills can be onboarded and continue building the application.
For such scalability, a comprehensive set of tools to build a web application is necessary and those that get you done using javascript are called Frameworks. AngularJS/Angular is one such framework.
#reactjs #web-development #javascript #front-end-development #programming #reactjs-application #javascript-frameworks #javascript-top-story
1596289080
React wrapper for mapboxgl-js API.
Made with by MeilleursAgents
import React from 'react';
import MapboxMap from 'react-mapbox-wrapper';
export default function SimpleMap() {
return (
<div style={{ height: 400, width: 400 }}>
<MapboxMap
accessToken="<your acess token here>"
coordinates={{ lat: 48.872198, lng: 2.3366308 }}
/>
</div>
);
}
SimpleMap.displayName = 'SimpleMap';
See examples folder for more example.
Read carefully the getting started section of Mapbox GL API.
If you use Webpack, you should add the following parameter in order to properly build your app.
module: {
noParse: /(mapbox-gl)\.js$/,
}
react-mapbox-wrapper
import the corresponding CSS stylesheet from Javascript, you don’t have to do it.
React Component that render a Mapbox Map. Extra props are directly passed to the Map constructor. Following props are handled by wrapper for updating or handling behavior in the React philosophy.
Wrapper is CSS flex-ready for width but you have to set a height for having visible Mapbox.
Props | Type | Default | Description |
---|---|---|---|
accessToken | String | required | Mapbox Access Token (find it here) |
coordinates | Object | required | Coordinates of the map center |
According to the LngLatLike model | |||
className | string | '' |
className added to map’s wrapper. Your should provide a height in order to render the map (default at 0) |
children | Node | null |
Rendered children, typically a Marker and/or Circle |
minZoom | number | undefined |
The minimum zoom level of the map (0-24). |
maxZoom | number | undefined |
The maximum zoom level of the map (0-24). |
zoom | number | 15 |
The viewport zoom |
onChange | func | undefined |
Callback function called on every viewport change (moveend , zoomend ) |
Callback receive param with the following shape
{ zoom: 15, coordinates: { lng: 3.4, lat: 1.2 } }
|
| onClick | func | undefined
| Callback function called on map’s click |
| onLoad | func | undefined
| Callback function called on map’s load with current Mapbox instance param |
| onZoomStart | func | undefined
| Callback function called on map’s zoomstart |
| onZoomEnd | func | undefined
| Callback function called on map’s zoomend with a debounce of 300ms in order to avoid too many render()
call |
| renderNotSupported | func | Simple message | Callback function called when browser does not support mapbox-gl |
| mapboxStyle | String | | Mapbox style layer |
| withCompass | bool | false
| Show compass Navigation Control |
| withFullscreen | bool | false
| Show Fullscreen Control |
| withZoom | bool | false
| Show zoom Navigation Control |
| fullscreenControlPosition | string | top-right
| Set Fullscreen Control position |
| navigationControlPosition | string | bottom-right
| Set Navigation Control position |
React Component that render a Marker. Extra props are directly passed to the Marker constructor
Props | Type | Default | Description |
---|---|---|---|
children | Node | null |
Marker HTML DOM, default marker will be used if not provided |
coordinates | Object | required | Coordinates of the marker |
According to the LngLatLike model | |||
draggable | bool | false |
Allow user to drag’n’drop Marker |
getRef | func | Callback function called with marker’s ref (useful for calling #moveToTop() function) |
|
map | Object | required | Mapbox Map where marker will be added (can be obtained with MapboxMap#onLoad props fn) |
onDragEnd | func | Callback function called on marker’s dragend | |
onMouseOut | func | Callback function called on marker or popup mouseOut | |
onMouseOver | func | Callback function called on marker or popup mouseOver | |
popup | Node | Popup attached to the marker, displayed on click to marker | |
popupAnchor | string | bottom |
Popup anchor param |
popupCloseButton | bool | false |
Popup closeButton param |
popupOffset | number | Popup offset param | |
popupOnOver | bool | false |
Trigger popup show on mouse over (only available if children are provided, default marker cannot be bind) |
React Component that render a Circle. Extra props are directly passed to the Marker constructor
Props | Type | Default | Description |
---|---|---|---|
coordinates | Object | required | Coordinates of the marker |
According to the LngLatLike model | |||
id | string | required | Identifier of circle, used to name the underlying layer |
map | Object | required | Mapbox Map where marker will be added (can be obtained with MapboxMap#onLoad props fn) |
onClick | func | Callback function called on circle’s click | |
paint | Object | Paint option of the layer | |
radius | number | required | Radius of circle, in kilometers |
unit | string | kilometers |
Unit of the radius. values can be : kilometers , meters , miles , feet |
We provide some helpers for interacting with Mapbox Map object, all in Helpers
import.
import { Helpers } from react-mapbox-wrapper;
Helpers.convertRadiusUnit(580, 'meters');
// > { radius: 0.58, unit: 'kilometers' }
Helpers.getCircleData({ lat: 48.868526, lng: 2.3434886 }, 800, 'meters')
// > Coordinates for drawing a circle with a 800meters radius at given coordinates
Helpers.coordinatesAreEqual({ lat: 48.868526, lng: 2.3434886 }, [2.3434886, 48.868526]);
// > Check if given coordinates are equal, even in different format
Helpers.newBounds(coordinatesSouthWest, coordinatesNorthEast);
// > Create a new LngLatBounds from Mapbox library
Helpers.newBound(coordinates);
// > Create a new LngLatLike from Mapbox library
Helpers.drawGeoJSON(map, 'foodTruck', data, { 'fill-opacity': 0.2 }, undefined, 'fill');
// > Draw a geoJSON with given data and type. Can be used to also update geoJSON if layer already exist
Helpers.removeGeoJSON(map, 'foodTruck');
// > Remove the layer previously added with #addGeoJSON method
npm install && npm run peers # install both dependencies and peers
You can use npm link
while developing new features on this repo for use in targeted repository.
npm link
You can use our pre-commit
hook for ensuring consistent format and linting before committing by running command:
./tools/install_hooks.sh
Author: MeilleursAgents
Live Demo: https://meilleursagents.github.io/react-mapbox-wrapper/
GitHub: https://github.com/MeilleursAgents/react-mapbox-wrapper
#javascript #react #reactjs
1622207074
Who invented JavaScript, how it works, as we have given information about Programming language in our previous article ( What is PHP ), but today we will talk about what is JavaScript, why JavaScript is used The Answers to all such questions and much other information about JavaScript, you are going to get here today. Hope this information will work for you.
JavaScript language was invented by Brendan Eich in 1995. JavaScript is inspired by Java Programming Language. The first name of JavaScript was Mocha which was named by Marc Andreessen, Marc Andreessen is the founder of Netscape and in the same year Mocha was renamed LiveScript, and later in December 1995, it was renamed JavaScript which is still in trend.
JavaScript is a client-side scripting language used with HTML (Hypertext Markup Language). JavaScript is an Interpreted / Oriented language called JS in programming language JavaScript code can be run on any normal web browser. To run the code of JavaScript, we have to enable JavaScript of Web Browser. But some web browsers already have JavaScript enabled.
Today almost all websites are using it as web technology, mind is that there is maximum scope in JavaScript in the coming time, so if you want to become a programmer, then you can be very beneficial to learn JavaScript.
In JavaScript, ‘document.write‘ is used to represent a string on a browser.
<script type="text/javascript">
document.write("Hello World!");
</script>
<script type="text/javascript">
//single line comment
/* document.write("Hello"); */
</script>
#javascript #javascript code #javascript hello world #what is javascript #who invented javascript
1616670795
It is said that a digital resource a business has must be interactive in nature, so the website or the business app should be interactive. How do you make the app interactive? With the use of JavaScript.
Does your business need an interactive website or app?
Hire Dedicated JavaScript Developer from WebClues Infotech as the developer we offer is highly skilled and expert in what they do. Our developers are collaborative in nature and work with complete transparency with the customers.
The technology used to develop the overall app by the developers from WebClues Infotech is at par with the latest available technology.
Get your business app with JavaScript
For more inquiry click here https://bit.ly/31eZyDZ
Book Free Interview: https://bit.ly/3dDShFg
#hire dedicated javascript developers #hire javascript developers #top javascript developers for hire #hire javascript developer #hire a freelancer for javascript developer #hire the best javascript developers
1589255577
As a JavaScript developer of any level, you need to understand its foundational concepts and some of the new ideas that help us developing code. In this article, we are going to review 16 basic concepts. So without further ado, let’s get to it.
#javascript-interview #javascript-development #javascript-fundamental #javascript #javascript-tips