//--------------------------------// This is a C#/XAML wrapper around the ArcGIS JavaScript library.// It makes it possible to use the ArcGIS JavaScript API in a CSHTML5 project.// The namespaces, classes, and methods mimic the Silverlight API so that developers who// are migrating their Silverlight apps to HTML/JS can do so without having to make changes// to their code, by simply referencing this wrapper DLL in a CSHTML5 project.// This project is meant to be compiled using CSHTML5 v1.0 Beta 7.2 or newer (more info: cshtml5.com)// The reference for the Silverlight API that this project attempts to mimic is available at:// https://developers.arcgis.com/silverlight/api-reference/#library-reference-overview.html//// This project is licensed under The open-source MIT license:// https://opensource.org/licenses/MIT// Copyright 2016 Userware / CSHTML5 (C#/XAML for HTML5)//--------------------------------

namespace ESRI.ArcGIS.Client{ /// <summary> /// Represents a Map control with a set of service layers that can be navigated using mouse and keyboard controls. /// Reference: https://developers.arcgis.com/silverlight/api-reference/#ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Map.html /// </summary> public class Map : Canvas { object _map; // Keeps a reference to the JavaScript "map" object. private double _zoom = 3;

/// <summary> /// Happens when the control is loaded into the Visual Tree. /// </summary> async void ArcGISMapControl_Loaded(object sender, RoutedEventArgs e) { // Get a reference to the HTML DOM representation of the control (must be in the Visual Tree): object div = Interop.GetDiv(this);

// Make sure that the Div has an ID, because the ArcGIS map controls requires an ID: Interop.ExecuteJavaScript("if (!$0.id) { $0.id = $1 }", div, Guid.NewGuid().ToString());

/// <summary> /// Happens when the control is unloaded from the Visual Tree. /// </summary> void ArcGISMapControl_Unloaded(object sender, RoutedEventArgs e) { // We release the reference to the Map object so that other code (such as "SetZoom") will not refresh the Map: _map = null; }

/// <summary> /// This callback is called by the JavaScript initialization code so as to keep a reference to the JS map object in the C# context. /// </summary> /// <param name="map"></param> void MethodToRememberJavaScriptMapObject(object map) { _map = map; }

/// <summary> /// The event handler that determines when the left mouse click has occurred in the Map Control. /// Reference: https://developers.arcgis.com/silverlight/api-reference/#ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Map~MouseClick_EV.html /// </summary> public event EventHandler<Map.MouseEventArgs> MouseClick;

In the Simulator you will notice a JavaScript warning when loading the map, and 2 warnings when clicking on the map. But you can safely ignore those warnings, as they won't appear in the final version when running in the browser.

When i traduce this HTML into a C#XAML .cs control, this is written this way:---- BEGIN C# ----- /// <summary> /// Happens when the control is loaded into the Visual Tree. /// </summary> async void ArcGISMapControl_Loaded(object sender, RoutedEventArgs e) { // Get a reference to the HTML DOM representation of the control (must be in the Visual Tree): object div = Interop.GetDiv(this);

// Make sure that the Div has an ID, because the ArcGIS map controls requires an ID: Interop.ExecuteJavaScript("if (!$0.id) { $0.id = $1 }", div, Guid.NewGuid().ToString());