1.0.34 • Published 4 months ago

my-library-masthanp v1.0.34

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

ESRI Logo

ESRI Map Component Library

A library for integrating ESRI-based map components into your React applications.

Installation

You can install the ESRI Map Component Library via npm or yarn:

npm install my-library-masthanp --save
# or
yarn add my-library-masthanp

Usage

After installation, you can use the MapComponent in your React application.

Basic Example

import { MapComponent } from "my-library-masthanp";

// 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)
};

Props

PropTypeDescription
mapConfigobjectA configuration object for the map (e.g., center, zoom, layers, etc.). Required.
zoombooleanDetermines whether to show the zoom buttons (default is true).
attributionsbooleanDetermines whether to show the map attributions (default is true).
afterViewCreateCallbackfunctionA callback function that is triggered after the map has been loaded.

Adding More Functionalities After Map Load

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);
};

Full Example in a React Component

import React from "react";
import { MapComponent } from "my-library-masthanp";
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;

License

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.
1.0.34

4 months ago

1.0.33

4 months ago

1.0.32

4 months ago

1.0.31

4 months ago

1.0.30

4 months ago

1.0.29

4 months ago

1.0.28

4 months ago

1.0.27

4 months ago

1.0.26

4 months ago

1.0.25

4 months ago

1.0.24

4 months ago

1.0.23

4 months ago

1.0.21

4 months ago

1.0.20

4 months ago

1.0.19

4 months ago

1.0.18

4 months ago

1.0.17

4 months ago

1.0.16

4 months ago

1.0.15

4 months ago

1.0.14

4 months ago

1.0.13

4 months ago

1.0.12

4 months ago

1.0.11

4 months ago

1.0.10

4 months ago

1.0.9

4 months ago

1.0.8

4 months ago

1.0.7

4 months ago

1.0.6

4 months ago

1.0.5

4 months ago

1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago