A library for integrating ESRI-based map components into your React applications.
You can install the ESRI Map Component Library via npm or yarn:
npm install @tasareeh/tasareeh_components --save
# or
yarn add @tasareeh/tasareeh_components
After installation, you can use the MapComponent
in your React application.
import { MapComponent } from "@tasareeh/tasareeh_components";
// Default map view is created if mapConfig is not passed as a property
<MapComponent
mapConfig={mapConfig} // Configuration object for the map (required)
zoom={true} // Boolean for showing or hiding the default zoom buttons
attributions={true} // Boolean for hiding or viewing the map attributions.
afterViewCreateCallback={handleMapLoad} // A callback function triggered after map load.
/>
// Example mapConfig object:
const mapConfig = {
basemap: "satellite", // Available options: satellite, streets, topographic, etc.
center: [78.9629, 20.5937], // Longitude, Latitude
zoom: 5, // Zoom level
width: "100%", // Map width (px or %)
height: "600px" // Map height (px)
};
Prop | Type | Description |
---|---|---|
mapConfig |
object |
A configuration object for the map (e.g., center, zoom, layers, etc.). Required. |
zoom |
boolean |
Determines whether to show the zoom buttons (default is true ). |
attributions |
boolean |
Determines whether to show the map attributions (default is true ). |
afterViewCreateCallback |
function |
A callback function that is triggered after the map has been loaded. |
Example of Adding a Layer After Map Load:
Once the map view is created, you can add further functionalities, such as adding a new layer:
// Example to add a MapImageLayer to the map after it has been loaded
const handleMapLoad = ({ map, view }) => {
const identifyLayer = new MapImageLayer({
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
});
map.add(identifyLayer);
};
import React from "react";
import { MapComponent } from "@tasareeh/tasareeh_components";
import MapImageLayer from "@arcgis/core/layers/MapImageLayer.js";
function App() {
const mapConfig = {
basemap: "satellite",
center: [78.9629, 20.5937],
zoom: 5,
width: "100%",
height: getMapHeight() + "px"
};
const handleMapLoad = ({ map, view }) => {
const identifyLayer = new MapImageLayer({
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
});
map.add(identifyLayer);
};
function getMapHeight() {
return window.innerHeight;
}
return (
<div>
<MapComponent
mapConfig={mapConfig}
zoom={true}
attributions={true}
afterViewCreateCallback={handleMapLoad}
/>
</div>
);
}
export default App;
This project is licensed under the MIT License.
MIT License
© 2025 Masthan Patan
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.