我只有城市的纬度和经度,我需要突出显示与城市边界链接相关的图像链接:https://prnt.sc/3adh6luxIhSE使用 Esri 地图的加拿大国家。
[ https://developers.arcgis.com/documentation/ ]
我遵循以下代码来获取这些功能。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ArcGIS Map with Marker and Boundary for Edmonton</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.24/esri/themes/light/main.css">
<style>
#viewDiv {
height: 500px;
width: 100%;
}
</style>
</head>
<body>
<div id="viewDiv"></div>
<script src="https://js.arcgis.com/4.24/"></script>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/Graphic",
"esri/geometry/Point",
"esri/symbols/SimpleMarkerSymbol",
"esri/Color",
"esri/layers/FeatureLayer",
"esri/config" // To set the API key
], function(Map, MapView, Graphic, Point, SimpleMarkerSymbol, Color, FeatureLayer, esriConfig) {
// Set your API key
esriConfig.apiKey = "YOUR_API_KEY";
// Create a map
var map = new Map({
basemap: "streets"
});
// Create a view
var view = new MapView({
container: "viewDiv",
map: map,
center: [-113.4909, 53.5444], // Edmonton coordinates
zoom: 12
});
// Create a point for the marker
var markerPoint = new Point({
longitude: -113.4909, // Edmonton longitude
latitude: 53.5444 // Edmonton latitude
});
// Create a simple marker symbol for the place marker
var markerSymbol = new SimpleMarkerSymbol({
color: new Color([0, 0, 255]), // Blue color
size: 10,
outline: {
color: new Color([255, 255, 255]),
width: 2
}
});
// Create a graphic with the point and marker symbol
var markerGraphic = new Graphic({
geometry: markerPoint,
symbol: markerSymbol
});
// Add the marker graphic to the view's graphics layer
view.graphics.add(markerGraphic);
// Create a feature layer for Edmonton's boundary (example URL, replace with actual service)
var edmontonBoundaryLayer = new FeatureLayer({
url: "https://services.arcgis.com/YOUR_ORGANIZATION/arcgis/rest/services/Edmonton_Boundary_Service/FeatureServer/0"
});
// Add the Edmonton boundary layer to the map
map.add(edmontonBoundaryLayer);
});
</script>
</body>
</html>
但是我如何在这些网址中查找和使用 YOUR_ORGANIZATION 和 Edmonton_Boundary_Service:**https://services.arcgis.com/YOUR_ORGANIZATION/arcgis/rest/services/Edmonton_Boundary_Service/FeatureServer/0 **
为我的查询提供建议,以使用加拿大国家的 Esri 地图添加此功能。
如果我错了,请纠正我。我在完全理解你的问题时遇到了一些麻烦。如果您正在寻找功能层的链接,快速谷歌搜索给了我这个链接。
您可以用该链接替换功能层中的链接。
var edmontonBoundaryLayer = new FeatureLayer({
url: "https://services8.arcgis.com/eplMbiqon7XDlULb/arcgis/rest/services/City_of_Edmonton_Neighbourhood_Boundaries/FeatureServer/0 "
});