bigscal-logo
  • bigscal-logo
  • Services
    • Software Development
          • Software Product Development
            • SaaS Consulting
            • MVP Development
            • Startup Product Development
            • Product UI/UX Design
            • Startup Consulting
          • Information Technology Consulting
            • Agile Consulting
            • Software Consulting
            • Data Analytics Consulting
            • CRM Consulting
          • Software Outsourcing
            • IT Staff Augmentation
            • Dedicated Development Teams
            • Shadow Engineers
            • Offshore Software Development
            • Offshore Development Center
            • White Label Services
          • Custom Software Development
            • Enterprise Software Development
            • Nearshore Software Development
          • Digital Transformation
    • Application Development
          • Mobile App Development
            • React Native App Development
            • iPhone app development
            • Android App Development
            • Flutter App Development
            • Cross Platform App Development
            • Xamarin App Development
          • Web Development
            • Website & Portal Development
          • Frontend Development
            • Angular Development
            • React.js Development
            • Next.js Development Services
          • Full Stack Development
            • MEAN Stack Development
            • MERN Stack Development
          • Backend Development
            • .NET Development
            • Node js Development
            • Laravel Development
            • PHP Development
            • Python Development
            • Java Development
            • WordPress Development
            • API Development
            • SharePoint Development
          • Cloud Application Development
            • Serverless Software Development
          • Application Maintenance
          • Application Modernization
    • QA & Testing
          • Penetration Testing
          • Usability Testing
          • Integration Testing
          • Security Testing
          • Automated Testing
          • Regression Testing
          • Vulnerability Assessment
          • Functional Testing
          • Software Performance Testing
          • QA Outsourcing
          • Web Application Testing
          • Software Quality Assurance Testers
          • Mobile App Testing
          • QA Consulting
          • Application Testing
    • eCommerce
          • eCommerce Web Design
          • Ecommerce Consulting
          • Digital Consulting
          • eCommerce Web Development
          • Supply Chain Automation
          • B2C eCommerce
          • B2B Ecommerce
    • Analytics & DevOps
          • Big Data Consulting
          • Business Intelligence Consulting
          • Microsoft Power BI
          • Power BI Implementation
          • DevOps Consulting
          • Amazon AWS
          • Microsoft Azure
    • Generative AI Development Services
          • Agentic AI Services
          • AI-ML Developers
          • Hire AI Developers
          • Machine Learning Developers
          • Deep Learning Development
          • IoT Developers
          • Chatbot Developers
  • Industries
    • Education & eLearning
    • Finance
    • Transportation & Logistics
    • Healthcare
      • Hospital Management Software Development
      • Patient Management Software Development
      • Clinic Management System
      • Telemedicine App Development Solutions
      • EMR Software
      • EHR Software
      • Laboratory Information Management Systems
    • Oil and Gas
    • Real Estate
    • Retail & E-commerce
    • Travel & Tourism
    • Media & Entertainment
    • Aviation
  • Hire Developers
    • Mobile Developers
          • Hire Android App Developers
          • Hire iOS App Developers
          • Hire Swift Developers
          • Hire Xamarin Developers
          • Hire React Native Developers
          • Hire Flutter Developers
          • Hire Ionic Developers
          • Hire Kotlin Developers
    • Web Developers
          • Hire .Net Developers
            • Hire ASP.NET Core Developers
          • Hire Java Developers
            • Hire Spring Boot Developers
          • Hire Python Developers
          • Hire Ruby On Rails Developers
          • Hire Php Developers
            • Hire Laravel Developers
            • Hire Codeigniter Developer
            • Hire WordPress Developers
            • Hire Yii Developers
            • Hire Zend Framework Developers
          • Hire Graphql Developers
    • Javascript Developers
          • Hire AngularJs Developers
          • Hire Node JS Developer
          • Hire ReactJS Developer
          • Hire VueJs Developers
    • Full Stack Developers
          • Hire MEAN Stack Developer
          • Hire MERN Stack Developer
    • Blockchain & Others
          • Hire Blockchain Developers
          • Hire Devops Engineers
          • Hire Golang Developers
  • Blogs
  • Careers
  • Company
    • Our Portfolio
    • About Us
    • Contact
  • Inquire Now
  • Menu Menu
Home1 / Frontend2 / Basic Implementation Using ArcGIS API for JavaScript with React
Explore the blend of ArcGIS API & React

Basic Implementation Using ArcGIS API for JavaScript with React

February 21, 2022/0 Comments/in Frontend /by Jainee Shah

Quick Summary: ArcGIS API for JavaScript with React combines Esri’s mapping capabilities with React’s component-based approach. It allows developers to build powerful mapping applications with ease. Users can access various geospatial functions and create responsive applications for web and mobile devices by integrating the ArcGIS API into React projects.

Introduction

Are you looking to build powerful web applications with maps? If so, check out the ArcGIS API for JavaScript with React!

The ArcGIS API for JavaScript is a highly adaptable library that offers a wide range of capabilities. It allows you to add interactive maps to your web applications easily. React is a modern JavaScript framework that makes creating quick and scalable user interfaces simple.

These two technologies together make an effective tool for building web applications that feature interactive maps. In this blog post, we will show you how to get started with basic implementation using ArcGIS API for JavaScript with React.

If you’re looking for a powerful and easy-to-use library for adding interactive maps to your web applications, you should check out the ArcGIS API for JavaScript with React. And to get better solutions, you will need to find the best React.JS Development Services. Also, you need to understand the Key Feature Of ReactJS will explain to you how ReactJS can help you to build the best applications.

What is GIS

GIS is all about interacting with maps using geographic data like where things are and how things are like there.

GIS provides a facility to understand the patterns between data. Eventually, it makes it easier to extract and understand all the related data.

Basics

To work with GIS in React ArcGIS provides an API for Javascript.

The concept of React is your UI should be a function of the state. Whereas Central philosophy of ArcGIS Javascript API is to give up an item ID and Dom node and they’ll give you the world, Literally.

On the ArcGIS side, First, we have to create a Map with initial properties like

  • basemap
  • portalItem etc

Secondly, we create a View that takes a reference to the map, container to display the map, and other additional properties. The view will be having properties like

  • map
  • container
  • center
  • zoom etc

Steps

1. Create a React app

npx create-react-app gisdemo

cd gisdemo

npm start

2. Install-Package in your Application

npm install esri-loader

3. Create React Functional Component Map.js in the components folder and Call it in App.js

import './App.css';
                    import Map from '../components/Map';
                    function App() {
                    return (
                    <div className="App">
                    <Map/>
                    </div>
                    );
                    }
                    export default App;

4. Create Container for map Using React Hooks

As discussed earlier API needs a container to Display the map. In React one has to use a Reference to a div. It can be achieved using useRef Hook. and for this you need to understand the Concept Of ReactJS Hooks.

import React,{useEffect,useRef} from 'react';
                    import { loadModules } from "esri-loader";
                    function Map() {
                    let view;
                    const MapElement = useRef(null);
                    return (
                    <div style={{height:800}} ref={MapElement}> 
                    </div>
                    );
                    }
                    export default Map;

5. Load the Modules using esri-loader Package

  • Map should be initialized right after the component is rendered. Therefore if you are using a Class component then the initialization will be placed in the lifecycle method componentDidMount() method.
  • In React Hooks the code will be written in useEffect Hook.
  • Load the required modules using loadModules Method and pass the CSS value as true.
useEffect(
                    ()=>{ 
                    loadModules(["esri/views/MapView", "esri/Map"],{
                    css:true
                    }).then(([MapView,Map])=>{ 
                    //Map will be created here 
                    });
                    });

6. Creating map Using React Hooks :

  • Basemap values can be
    • dark-gray
    • dark-gray-vector
    • topo-vector
    • streets-navigation-vector
    • hybrid
    • topo
    • oceans
    • streets-relief-vector
    • satellite
    • streets
    • gray-vector
    • streets-night-vector
    • osm
    • streets-vector
    • terrain
    • national-geographic
    • gray
  • Map Without an Api Key :
  • loadModules(["esri/views/MapView","esri/Map"],{
                
                        css:true
                
                        }).then(([MapView,Map])=>{
                
                        const map = new Map({
                
                        basemap:'topo-vector',
                
                        });
                
                        });
  • Map With an API Key :
          • To get API Key :
          • ArcGIS Maps SDK for JavaScript
  • loadModules(["esri/views/MapView","esri/Map","esri/config"],{
                        css:true
                        }).then(([MapView,Map,esriConfig])=>{ 
                        esriConfig.apiKey = "YOUR_API_KEY";
                        const map=new Map({
                        basemap:'topo-vector'
                        portalItem:{
                        id:"d7e8cd6ae3854af6b2ed3a34609b8165"
                        }
                        });
                        });
                        });

7. Creating View

  • The initialization code will be the same as ArcGIS code samples.
  • The only thing to keep in mind is to assign the current value of a reference to the container.
  • View can be of two types :
    • MapView (2D) – “esri/views/MapView”
    • SceneView (3D) – “esri/views/SceneView”
  • view = new MapView({
                        zoom: 14, //Zoom Level can be Between 0 to 23
                        center: [-118.24, 34.05], //longitude, latitude
                        container:MapElement.current,
                        map: map //map created above
                        });

8. Adding GeoJson or KML layer to your Map

  • One can add layers on the map using stored Geographical Data
  • You can pass the URL of the Kml or GeoJSON file as a parameter and add that layer to the map.
  • Modules to Load For GeoJSON Layer :
    • “esri/layers/GeoJSONLayer” – GeoJSONLayer
const geoJsonLayer = new GeoJSONLayer({
                    url : "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson"
                    });
                    map.add(geoJsonLayer)
  • Modules to Load For KML Layer :
    • “esri/layers/KMLLayer” – KMLLayer
    • If you want to add a KML file from your Device,
      • Expose a web server on Port like 5500 of your local machine to the internet.
      • You can use ngrok for that and get the url for your kml file stored on a local machine.
let layer = new KMLLayer({
                    url: "http://99b2-43-224-10-137.ngrok.io/ITCompanies.kml"
                    });
                    map.add(layer)

All the above code will be written in useEffect hook.

Conclusion

Integrating ArcGIS API for JavaScript with React provides a powerful and efficient geospatial data visualization and analysis toolset. This basic implementation showcases the seamless combination of React’s component-based architecture and ArcGIS’s robust mapping capabilities.

Leveraging React’s virtual DOM and ArcGIS’s extensive geospatial functionalities allows developers to create dynamic and interactive mapping applications.

By adhering to ethical practices and acknowledging the importance of plagiarism-free content, we ensure the integrity of our work and respect the contributions of others in the field. Embracing this integration opens opportunities to create innovative and engaging web-based GIS applications that focus on authenticity and originality.

FAQ

What is ArcGIS API for JavaScript with React?

ArcGIS API for JavaScript with React combines Esri’s ArcGIS API for JavaScript and the React library, enabling developers to build interactive mapping applications using React components.

How do I get started with ArcGIS API for JavaScript with React?

Install the required packages, create a new React project, and then integrate ArcGIS API for JavaScript within your React components.

Can I use ArcGIS API for JavaScript with React in my existing React project?

You can integrate ArcGIS API for JavaScript into your existing React project by following the installation and configuration steps.

What is the benefit of using ArcGIS API for JavaScript with React?

By combining ArcGIS API for JavaScript with React, you get the benefits of a powerful mapping API and the component-based architecture of React, allowing for easy management of UI components and states.

Is ArcGIS API for JavaScript free to use with React?

ArcGIS API for JavaScript has different licensing options. While it offers a free developer subscription for testing and development, production use may require a paid license.

Tags: #arcgis, #bigscal, #bigscal Technologies, #front-end developer, #front-end framework developer, #frontend, #frontend technology, #Geographic Information System, #react, #react.js

You might also like

React.JS vs Python: The Tech Battle React js vs Python: Which is better?
Dive into development: ReactJs or VanillaJs ReactJs Vs VanillaJs: Choose The Best For Development
Discover the top 13 React tools Software Developers absolutely need to know Top 13 React Tools That Every Software Developer Should Know
Paving the Way with AWS S3 & NodeJS How to use AWS S3 Bucket with NodeJS Application?
conversion rate optimization What is Conversion Rate Optimization?
Take Charge with Advanced Mongoose Filters The Ultimate List of Mongoose Advance Filtration Implementations

Seeking robust and scalable software solutions?

Contact us for industry-leading development services.

Book a 30 min FREE Call

Craft your Best Agile Team

Your Project, Our Expertise - Hire a Developer Now

    Subscribe for
    weekly updates

      privacy-policy I accept the terms and conditions

      Categories

      • AI-ML-Blockchain
      • Aviation
      • Backend
      • Cloud
      • Cross Platform
      • Cyber Security
      • Database
      • DevOps
      • Digital Marketing
      • Ecommerce
      • Education Industry
      • Entertainment Industry
      • Fintech Industries
      • Frontend
      • Full Stack
      • Game Development
      • Healthcare Industry
      • Latest Technology News
      • Logistics Industry
      • Mobile app development
      • Oil And Gas Industry
      • Plugins and Extensions
      • QA & Testing
      • Real Estate Industry
      • SaaS
      • Software Development
      • Top and best Company
      • Travel industries
      • UI UX
      • Website Development

      Table of Content

      bigscal-technology
      india
      1st Floor, B - Millenium Point,
      Opp. Gabani Kidney Hospital,
      Lal Darwaja Station Rd,
      Surat – 395003, Gujarat, INDIA.
      us
      1915, 447 Broadway,
      2nd Floor, New York,
      US, 10013
      +91 7862861254
      [email protected]

      • About
      • Career
      • Blog
      • Terms & Conditions
      • Privacy Policy
      • Sitemap
      • Contact Us
      Google reviews
      DMCA.com Protection Status
      GoodFirms Badge
      clutch-widget
      © Copyright - Bigscal - Software Development Company
      Google reviews
      DMCA.com Protection Status
      GoodFirms Badge
      clutch-widget

      Stay With Us

      Are you looking for the perfect partner for your next software project?

      Google reviews GoodFirms Badge clutch-widget
      • IP Rights, Security & NDA. Full ownership and confidentiality with robust security guaranteed.
      • Flexible Contracts & Transparency. Tailored contracts with clear and flexible processes.
      • Free Trial & Quick Setup. No-risk trial and swift onboarding process.

        Basic Concept of ReactJS Hooks Explore ReactJS Hooks: Revolutionize Your Code! Unlock the Power of Mutation Observer What is Mutation Observer and how to use it?
        Scroll to top

        We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

        AcceptHide notification onlySettings

        Cookie and Privacy Settings



        How we use cookies

        We may request cookies to be set on your device. We use cookies to let us know when you visit our websites, how you interact with us, to enrich your user experience, and to customize your relationship with our website.

        Click on the different category headings to find out more. You can also change some of your preferences. Note that blocking some types of cookies may impact your experience on our websites and the services we are able to offer.

        Essential Website Cookies

        These cookies are strictly necessary to provide you with services available through our website and to use some of its features.

        Because these cookies are strictly necessary to deliver the website, refuseing them will have impact how our site functions. You always can block or delete cookies by changing your browser settings and force blocking all cookies on this website. But this will always prompt you to accept/refuse cookies when revisiting our site.

        We fully respect if you want to refuse cookies but to avoid asking you again and again kindly allow us to store a cookie for that. You are free to opt out any time or opt in for other cookies to get a better experience. If you refuse cookies we will remove all set cookies in our domain.

        We provide you with a list of stored cookies on your computer in our domain so you can check what we stored. Due to security reasons we are not able to show or modify cookies from other domains. You can check these in your browser security settings.

        Other external services

        We also use different external services like Google Webfonts, Google Maps, and external Video providers. Since these providers may collect personal data like your IP address we allow you to block them here. Please be aware that this might heavily reduce the functionality and appearance of our site. Changes will take effect once you reload the page.

        Google Webfont Settings:

        Google Map Settings:

        Google reCaptcha Settings:

        Vimeo and Youtube video embeds:

        Privacy Policy

        You can read about our cookies and privacy settings in detail on our Privacy Policy Page.

        Privacy Policy
        Accept settingsHide notification only