<\/P>
Of course, Esri itself also offers extensive documentation, with examples and exercises,
Hoi Egge-Jan,
Dank je voor de info. Het lukt me echter niet om hetzelfde te verwezenlijken voor België als jij hier hebt gedaan voor Nederland.
Ik zou graag net als jij enkel België zichtbaar hebben voor de info, maar ik weet niet waar dit te vinden. Na wat speurwerk heb ik de RDstelsel gevonden: 31370, maar als ik dit gebruik kom ik ergens anders op de wereld uit. Daarom dat ik nu dit gebruik: center: [4.402771, 51.260197]
Zou je me in de juiste richting kunnen duwen?
Dit is mijn code so far. Ik heb ook de click functie er al op zodat je een locatie met reverse geocoding kan opsnorren.
Boven de basemap maak ik dan gebruik van een GRB basiskaart van Vlaanderen via WMS.
<!DOCTYPE html><html><head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"> <title>Aan de slag met ArcGIS JavaScript - Nederlandse basiskaart</title> <style> html, body, #viewDiv { padding: 0; margin: 0; height: 100%; width: 100%; } </style><link rel="stylesheet" href="https://js.arcgis.com/4.11/esri/css/main.css"> <script src="https://js.arcgis.com/4.11/"></script><script> var map, view, layer;require([ "esri/tasks/Locator", "esri/Map", "esri/geometry/Point", "esri/views/MapView", "esri/widgets/Search", "esri/layers/WMSLayer" ], function (Locator, Map, Point, MapView, Search, WMSLayer) { layer = new WMSLayer({ url: 'https://geoservices.informatievlaanderen.be/raadpleegdiensten/GRB-basiskaart/wms' });var locatorTask = new Locator({ url: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer" });map = new Map({ basemap: "topo-vector" //Dit is je basismap om in te lezen });map.add(layer); //Hier is de WMS layer die je erop "plakt"var rdOrigin = new Point({ y: 155763.88, x: 132693.38 , spatialReference: 31370 }); view = new MapView({ map: map, zoom: 9, center: [4.402771, 51.260197], //lon, lat <!-- center: rdOrigin, --> container: "viewDiv" }); var search = new Search({ view: view });view.ui.add([search], "top-right"); /******************************************************************* * This click event sets generic content on the popup not tied to * a layer, graphic, or popupTemplate. The location of the point is * used as input to a reverse geocode method and the resulting * address is printed to the popup content. *******************************************************************/ view.popup.autoOpenEnabled = false; view.on("click", function (event) { // Get the coordinates of the click on the view var lat = Math.round(event.mapPoint.latitude * 1000) / 1000; var lon = Math.round(event.mapPoint.longitude * 1000) / 1000;view.popup.open({ // Set the popup's title to the coordinates of the location title: "Reverse geocode: [" + lon + ", " + lat + "]", location: event.mapPoint // Set the location of the popup to the clicked location });// Display the popup // Execute a reverse geocode using the clicked location locatorTask .locationToAddress(event.mapPoint) .then(function (response) { // If an address is successfully found, show it in the popup's content view.popup.content = response.address; }) .catch(function (error) { // If the promise fails and no result is found, show a generic message view.popup.content = "No address was found for this location"; }); }); }); </script></head><body> <div id="viewDiv"></div></body></html>
<!DOCTYPE html><html><head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"> <title>Aan de slag met ArcGIS JavaScript - Nederlandse basiskaart</title> <style> html, body, #viewDiv { padding: 0; margin: 0; height: 100%; width: 100%; } </style>
<link rel="stylesheet" href="https://js.arcgis.com/4.11/esri/css/main.css"> <script src="https://js.arcgis.com/4.11/"></script>
<script> var map, view, layer;
require([ "esri/tasks/Locator", "esri/Map", "esri/geometry/Point", "esri/views/MapView", "esri/widgets/Search", "esri/layers/WMSLayer" ], function (Locator, Map, Point, MapView, Search, WMSLayer) { layer = new WMSLayer({ url: 'https://geoservices.informatievlaanderen.be/raadpleegdiensten/GRB-basiskaart/wms' });
var locatorTask = new Locator({ url: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer" });
map = new Map({ basemap: "topo-vector" //Dit is je basismap om in te lezen });
map.add(layer); //Hier is de WMS layer die je erop "plakt"
var rdOrigin = new Point({ y: 155763.88, x: 132693.38 , spatialReference: 31370 });
view = new MapView({ map: map, zoom: 9, center: [4.402771, 51.260197], //lon, lat <!-- center: rdOrigin, --> container: "viewDiv" });
var search = new Search({ view: view });
view.ui.add([search], "top-right");
/******************************************************************* * This click event sets generic content on the popup not tied to * a layer, graphic, or popupTemplate. The location of the point is * used as input to a reverse geocode method and the resulting * address is printed to the popup content. *******************************************************************/ view.popup.autoOpenEnabled = false; view.on("click", function (event) { // Get the coordinates of the click on the view var lat = Math.round(event.mapPoint.latitude * 1000) / 1000; var lon = Math.round(event.mapPoint.longitude * 1000) / 1000;
view.popup.open({ // Set the popup's title to the coordinates of the location title: "Reverse geocode: [" + lon + ", " + lat + "]", location: event.mapPoint // Set the location of the popup to the clicked location });
// Display the popup // Execute a reverse geocode using the clicked location locatorTask .locationToAddress(event.mapPoint) .then(function (response) { // If an address is successfully found, show it in the popup's content view.popup.content = response.address; }) .catch(function (error) { // If the promise fails and no result is found, show a generic message view.popup.content = "No address was found for this location"; }); }); }); </script></head><body> <div id="viewDiv"></div></body></html>
Hoi Serge,
De kaart die ik in de blog hierboven maak (en die ik in deze oefening wat verder uitwerk) is gebaseerd op het feit dat de Nederlandse reseller van Esri (Esri Nederland) allerlei kaarten en data aanbiedt in het Nederlandse projectiesysteem: het RD-stelsel met de code 28992. (RD staat voor het stelsel van de Rijksdriehoeksmeting; dit is aan het begin van de 19e eeuw opgezet door soldaten van Napoleon, tijdens de Franse bezetting.)
Het Belgische nationale systeem, Lambert 1972, heeft als code inderdaad 31370. Maar ik weet niet of Esri Belux, net als in Nederland, allerlei materiaal in deze projectie aanbiedt.
Als ik jouw was zou ik dus bij het standaard kaartmateriaal van Esri Wereldwijd blijven. Deze kaarten zijn in in de Web Mercator projectie (Spatial Reference: 102100 (3857)).
Hier overheen kun je dan het materiaal van informatievlaanderen projecteren, zoals de WMS met het Grootschalig Referentiebestand (GRB) die je al gebruikt hebt.
Tip: bouw een Home widget in, zodat men, als men in de kaart te ver van Vlaanderen afdrijft, met één druk op de knop weer naar 'huis' kan gaan.
Ik hoop dat je hier wat mee kan.
Groet,
Egge-Jan
Dank je Egge-Jan! Dan behou ik verlopig hoe het nu is.
Ondertussen steekt de Home widget erin
Groeten,
Serge
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.