Interactive GIS with React and ArcGIS: A Real-World Use-Case cover

Interactive GIS with React and ArcGIS: A Real-World Use-Case

08/02/2025 • By Variant Systems

At Variant Systems, we’re continually pushing the boundaries of how businesses interact with spatial data. In our previous blog, Harness GIS Data for Strategic Business Innovation, we explored how GIS transforms raw spatial data into strategic business insights. Building on that foundation, today we dive into a modern approach: integrating React with the ArcGIS SDK to create dynamic, interactive GIS applications. In this post, we’ll explore a real-world use-case that demonstrates how this integration can revolutionize your data visualization and decision-making processes.

Why Combine React with ArcGIS SDK?

Modern web applications demand interactivity, scalability, and performance. React, a leading JavaScript library for building user interfaces, offers an efficient way to manage complex state and create responsive, component-driven applications. When paired with the ArcGIS SDK—which provides robust mapping and spatial analysis tools—businesses can build applications that truly bring geographic data to life.

  • Seamless Integration: React’s component-based architecture aligns perfectly with the modular nature of the ArcGIS SDK.
  • Enhanced User Experience: Dynamic, interactive maps and real-time data updates engage users and drive actionable insights.
  • Scalability: Both React and the ArcGIS SDK are designed to handle large datasets and complex operations, making them ideal for enterprise-level applications.

Use-Case Overview: Real-Time Asset Tracking

Imagine a scenario where your organization needs to monitor a fleet of vehicles in real time. Leveraging React and the ArcGIS SDK, you can develop a robust asset tracking system that displays live vehicle locations, routes, and status updates on an interactive map.

Key Features of the Application

  • Interactive Mapping: Visualize live data with dynamic map views.
  • Real-Time Updates: Continuously stream location data via WebSockets or REST APIs.
  • Responsive Design: Deliver a seamless experience across desktops, tablets, and mobile devices.
  • Custom Overlays: Highlight critical information with tailored markers and layers.

Building the Application

Developing a real-time asset tracking system involves several key steps. Below is an overview of the process with placeholders for the code implementations that power each phase.

Setting Up the React Application

Begin by setting up your React environment. Create a new project and install the necessary dependencies to establish the backbone of your application. This step ensures you have a modular and maintainable codebase ready to integrate with GIS functionality.

npx create-react-app real-time-asset-tracking
cd real-time-asset-tracking
npm install @arcgis/core

Integrating the ArcGIS SDK

Next, integrate the ArcGIS SDK into your React project. Configure the SDK and embed the map component within your application. Set up the initial map views, layers, and controls to manage user interactions and display spatial data effectively.

import React, { useRef, useEffect } from "react";
import Map from "@arcgis/core/Map";
import MapView from "@arcgis/core/views/MapView";

const ArcGISMap = ({ assets }) => {
  const mapDiv = useRef(null);

  useEffect(() => {
    const map = new Map({
      basemap: "streets-vector",
    });
    const view = new MapView({
      container: mapDiv.current,
      map: map,
      center: [-118.71511, 34.09042], // Longitude, latitude
      zoom: 11,
    });

    // Example: Add markers for each asset (to be implemented with proper graphics layers)
    if (assets && assets.length > 0) {
      assets.forEach((asset) => {
        // Placeholder for asset marker implementation
        console.log("Asset data:", asset);
      });
    }

    return () => {
      if (view) {
        view.destroy();
      }
    };
  }, [assets]);

  return <div style={{ width: "100%", height: "500px" }} ref={mapDiv} />;
};

export default ArcGISMap;

Implementing Real-Time Data Updates

Bring your map to life by implementing real-time data fetching. Whether you choose WebSockets or RESTful APIs, the goal is to continuously update the map with live asset data. This integration ensures that users always see the most current information available.

import React, { useState, useEffect } from "react";
import ArcGISMap from "./ArcGISMap";

const AssetTracker = () => {
  const [assets, setAssets] = useState([]);

  useEffect(() => {
    // Connect to a WebSocket server for real-time asset updates
    const ws = new WebSocket("wss://example.com/asset-tracker");

    ws.onmessage = (event) => {
      const data = JSON.parse(event.data);
      // Update assets state with the new data
      setAssets((prevAssets) => [...prevAssets, data]);
    };

    ws.onerror = (error) => {
      console.error("WebSocket error:", error);
    };

    return () => {
      ws.close();
    };
  }, []);

  return (
    <div>
      <ArcGISMap assets={assets} />
      {/* Additional UI components to display asset info can be added here */}
    </div>
  );
};

export default AssetTracker;

Managing State and Performance

With real-time data streaming in, efficient state management is critical. Leverage React’s state management techniques—using hooks or lifecycle methods—to ensure smooth updates without compromising performance. Consider strategies like debouncing updates or memoizing components to optimize rendering.

import React, { useMemo } from "react";

const AssetMarkers = React.memo(({ assets }) => {
  const markers = useMemo(() => {
    return assets.map((asset, index) => (
      <div
        key={index}
        style={{
          position: "absolute",
          left: asset.screenX,
          top: asset.screenY,
          transform: "translate(-50%, -50%)",
          background: "red",
          borderRadius: "50%",
          width: "10px",
          height: "10px",
        }}
        title={`Asset ID: ${asset.id}`}
      ></div>
    ));
  }, [assets]);

  return <>{markers}</>;
});

export default AssetMarkers;

Overcoming Challenges and Best Practices

While integrating React with the ArcGIS SDK opens up powerful opportunities, it also introduces unique challenges. Here are some best practices to help you navigate the integration:

  • Asynchronous Data Handling: Use asynchronous programming patterns to manage data fetching and state updates without blocking the UI.
  • Performance Optimization: Monitor rendering performance, especially with large datasets or frequent updates. Tools like the React Profiler can help identify bottlenecks.
  • Error Handling: Implement robust error handling, particularly when dealing with external APIs and real-time data feeds.
  • Modular Code Structure: Keep your code organized by compartmentalizing components and logic. This improves maintainability and simplifies future enhancements.

Conclusion

The fusion of React and the ArcGIS SDK opens up a world of possibilities for creating dynamic, interactive GIS applications. Our real-world use-case of a real-time asset tracking system demonstrates how modern web technologies can transform raw spatial data into actionable insights, driving operational efficiency and informed decision-making.

At Variant Systems, we are dedicated to helping businesses harness the power of innovative technologies. Ready to take your GIS applications to the next level? Contact Variant Systems today to discover how our tailored solutions can empower your organization with cutting-edge, data-driven insights.

Transform Your Business with Expert Solutions

Looking for similar expertise for your business? Our team of experts is ready to help you achieve your digital transformation goals.