You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ArcGIS集成地块管理系统:地图创建与数据转换技术求助

Hey there! Let’s walk through how to build your plot management system with ArcGIS integration—this is a super common use case, so I’ve got practical steps to help you out.

1. Creating Your ArcGIS Map

You’ve got two solid paths here, depending on how much customization you need:

Option 1: ArcGIS Online (No-Code/Low-Code)

Perfect if you want to get up and running fast without heavy dev work:

  • Log into ArcGIS Online, create a new Web Map.
  • Add your plot data layer (you can upload Shapefiles, GeoJSON, or connect to a published feature service later). Pick a base map that fits your use case (like streets or satellite imagery).
  • Style your plot layer (e.g., color-code plots by type) to make it user-friendly.
  • Save the map, grab its Item ID—you’ll use this to embed or access the map in your website later.

Option 2: ArcGIS API for JavaScript (Full Customization)

Use this if you need total control over the map’s look and behavior:
Here’s a minimal working example to embed a map in your site:

require([
  "esri/Map",
  "esri/views/MapView",
  "esri/layers/FeatureLayer"
], function(Map, MapView, FeatureLayer) {
  // Initialize map with a base map
  const map = new Map({
    basemap: "streets-navigation-vector"
  });

  // Bind map to a div in your HTML (give the div an ID like "mapDiv")
  const view = new MapView({
    container: "mapDiv",
    map: map,
    center: [36.8219, -1.2921], // Replace with your region's default coordinates
    zoom: 12
  });

  // Add your plot data as a feature layer (replace with your service URL)
  const plotLayer = new FeatureLayer({
    url: "https://your-arcgis-server-url/arcgis/rest/services/YourPlotService/FeatureServer/0"
  });
  map.add(plotLayer);
});
2. Implementing Plot Search by Land Certificate Number

This is where users input a certificate ID and get a map location + details. Here’s how to build it:

Step 1: Publish Your Plot Data as a Feature Service

First, you need to make your database plot data accessible to ArcGIS:

  • Ensure your database (MySQL, PostgreSQL, etc.) has a certificate_id field and spatial data (like WKT geometry or latitude/longitude bounds).
  • Use ArcGIS Pro or ArcGIS Online to import your database data and publish it as a Feature Service. This lets the ArcGIS API query and display the plots.

Step 2: Build the Search Function

Use ArcGIS’s QueryTask to fetch the plot matching the user’s input:

require([
  "esri/tasks/QueryTask",
  "esri/tasks/support/Query"
], function(QueryTask, Query) {
  // Point to your feature service
  const queryTask = new QueryTask({
    url: "https://your-arcgis-server-url/arcgis/rest/services/YourPlotService/FeatureServer/0"
  });

  // Get the user's input from your search field
  const certificateId = document.getElementById("certificate-search").value;

  // Build the query to find the matching plot
  const query = new Query({
    where: `certificate_id = '${certificateId}'`, // Replace with your database field name
    returnGeometry: true, // Grab the plot's shape for mapping
    outFields: ["*"] // Fetch all plot attributes to display
  });

  // Run the query and handle results
  queryTask.execute(query).then(results => {
    if (results.features.length > 0) {
      const matchedPlot = results.features[0];
      // Zoom the map to the plot smoothly
      view.goTo(matchedPlot.geometry, { duration: 1000 });
      // Show a popup with plot details
      view.popup.open({
        features: [matchedPlot],
        location: matchedPlot.geometry.centroid
      });
    } else {
      alert("No plot found with that certificate number.");
    }
  }).catch(error => {
    console.error("Search failed:", error);
  });
});
3. Bidirectional Data Conversion (Map ↔ Database)

You need to translate between ArcGIS’s geometry objects and your database’s spatial format—here’s how:

Map → Database (Saving/Updating Plots)

If users edit plots on the map (e.g., draw new boundaries), convert ArcGIS geometry to a database-friendly format like WKT:

// Get the edited plot's geometry from the map
const updatedGeometry = editedPlot.geometry;
// Convert to WKT (works with most spatial databases)
const wktGeometry = updatedGeometry.toJSON().wkt;

// Send to your backend API to update the database
fetch("/api/update-plot", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    certificate_id: certificateId,
    geometry: wktGeometry,
    // Add other plot attributes here
  })
});

On the backend, use your database’s spatial functions (e.g., PostGIS’s ST_GeomFromText) to store the WKT as a spatial object.

Database → Map (Loading Plots)

If your database stores WKT/GeoJSON, ArcGIS’s feature service will handle conversion automatically. If you’re fetching data directly from your backend:

// Fetch plot data from your API
fetch(`/api/get-plot?certificate_id=${certificateId}`)
  .then(res => res.json())
  .then(plotData => {
    // Convert database WKT to ArcGIS geometry
    const plotGeometry = esri.geometry.fromJSON({
      wkt: plotData.geometry
    });
    // Create a graphic to add to the map
    const plotGraphic = new esri.Graphic({
      geometry: plotGeometry,
      attributes: plotData,
      symbol: {
        type: "simple-fill",
        color: [255, 0, 0, 0.5],
        outline: { color: [0, 0, 0], width: 1 }
      }
    });
    // Add the plot to the map view
    view.graphics.add(plotGraphic);
  });
4. Pro Tips for a Smooth Implementation
  • Index Your Database: Add indexes to the certificate_id field and spatial fields to speed up queries.
  • Secure Access: Restrict your feature service to authorized users only, and validate all user input in your backend to prevent SQL injection.
  • Test with Small Data: Start with a small dataset to work out kinks before scaling to your full plot inventory.

内容的提问来源于stack exchange,提问作者Kelvin Mwangi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:09:59