<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ArcGIS Maps SDK for JavaScript example: custom button (calcite-action with SVG) in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-maps-sdk-for-javascript-example-custom/m-p/1254669#M80149</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can you add your own custom buttons to an ArcGIS JavaScript application, one with your own picture, I mean? &lt;A href="https://twiav.nl/tutorial/arcgis/javascript/arcgis_javascript_example_custom_button.htm" target="_blank" rel="noopener"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-right" image-alt="ArcGIS Maps SDK for JavaScript example: custom button" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62016i62B28299C5548FB9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="arcgis_javascript_example_custom_button.png" alt="ArcGIS Maps SDK for JavaScript example: custom button" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;ArcGIS Maps SDK for JavaScript example: custom button&lt;/span&gt;&lt;/span&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The SDK comes with a load of widgets, all with their own icons, and for your custom buttons there is a whole set of &lt;A href="https://developers.arcgis.com/javascript/latest/esri-icon-font/" target="_blank" rel="noopener"&gt;Esri Icon Fonts (Calcite theme)&lt;/A&gt; available.&lt;/P&gt;&lt;P&gt;But now I want to add my own icon, is that possible? I stumbled into this post &lt;A href="https://community.esri.com/t5/calcite-design-system-questions/use-of-custom-icon/td-p/1169445" target="_blank" rel="noopener"&gt;use of custom icon&lt;/A&gt;, where it was suggested to use &lt;A href="https://developers.arcgis.com/calcite-design-system/components/action/" target="_self"&gt;calcite-action.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;And yeah, with this information I managed to use my own SVG image in a button - see code below.&lt;/P&gt;&lt;P&gt;It is a &lt;A href="https://twiav.nl/tutorial/arcgis/javascript/nederland.svg" target="_self"&gt;huge image&lt;/A&gt; - 924 by 924 pixels! - but because it is a fully Scalable Vector Graphic I can squeeze it down to 25x25px. And to stick with the Esri branded theme I use a fill color of #6e6e6e. In this way it fits in nicely with the rest of the UI.&lt;/P&gt;&lt;P&gt;What do you think?&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Egge-Jan&lt;/P&gt;&lt;P&gt;&lt;A href="https://twiav.nl/tutorial/arcgis/javascript/arcgis_javascript_example_custom_button.htm" target="_blank"&gt;TWIAV | ArcGIS JavaScript example - custom button&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="utf-8"&amp;gt;
  &amp;lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"&amp;gt;
  &amp;lt;title&amp;gt;TWIAV | ArcGIS JavaScript example - custom button&amp;lt;/title&amp;gt;
  &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.25/esri/css/main.css"&amp;gt;
  &amp;lt;script src="https://js.arcgis.com/4.25/"&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;style&amp;gt;
    html, body {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
      font-family: sans-serif;
    }
    #header {	
    	width: 100%;
        height: 70px;
        background-color: #154273;
        color:#FFFFFF;
        margin: 0;
    }
    #headertext {
        float: left;
        font-size: 35px;
        color: white;
        line-height: 70px;
        padding-left: 15px;
    }
    #viewDiv {
        position: absolute;
        top: 70px;
        bottom: 0;
        right: 0;
        left: 0;
        padding: 0;
        margin: 0;
    }
  &amp;lt;/style&amp;gt;
  &amp;lt;script&amp;gt;  
      require([
        "esri/Map",
        "esri/geometry/Point",
        "esri/views/MapView"
      ], function(Map, Point, MapView) {

      const map = new Map({
        basemap: { portalItem: { id: "7aea6fa913a94176a1074edb40690318" } } // Topo RD --&amp;gt; https://www.arcgis.com/home/item.html?id=7aea6fa913a94176a1074edb40690318
      });

      const view = new MapView({
        spatialReference: 28992, 
        container: "viewDiv",
        map: map,
        center: new Point({ x: 145430, y: 427100, spatialReference: 28992 }),
        zoom: 10
      });
      
      view.when(() =&amp;gt; {
        createZoomEntireCountryBtn();
        view.ui.add(["zoomEntireCountryBtn"], "top-left")
      });

      /*******************************************************************************
       * Start zoom to entire country
       *******************************************************************************/
      function createZoomEntireCountryBtn() {
        const zoomEntireCountryBtnDiv = document.createElement('div');
        zoomEntireCountryBtnDiv.innerHTML = `
          &amp;lt;div id="zoomEntireCountryBtn" class="esri-component esri-widget--button esri-widget" role="button"&amp;gt;
            &amp;lt;span title="Zoom uit op heel Nederland"&amp;gt;&amp;lt;calcite-action&amp;gt;&amp;lt;img src="nederland.svg" style="width:25px;height:25px;" alt="nederland"&amp;gt;&amp;lt;/calcite-action&amp;gt;&amp;lt;/span&amp;gt;
          &amp;lt;/div&amp;gt;`;
        document.body.appendChild(zoomEntireCountryBtnDiv);
        document.getElementById("zoomEntireCountryBtn").addEventListener("click", zoomEntireCountry);
      }
      
      function zoomEntireCountry() {
        view.goTo({
          center: new Point({ x: 155000, y: 463000, spatialReference: 28992 }),
          zoom: 3
        });
      }
      /*******************************************************************************
       * End zoom to entire country
       *******************************************************************************/
    });
  &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;div id="header"&amp;gt;
      &amp;lt;div id="headertext" class="stretch"&amp;gt;ArcGIS Maps SDK for JavaScript example: custom button&amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Feb 2023 22:59:17 GMT</pubDate>
    <dc:creator>Egge-Jan_Pollé</dc:creator>
    <dc:date>2023-02-02T22:59:17Z</dc:date>
    <item>
      <title>ArcGIS Maps SDK for JavaScript example: custom button (calcite-action with SVG)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-maps-sdk-for-javascript-example-custom/m-p/1254669#M80149</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can you add your own custom buttons to an ArcGIS JavaScript application, one with your own picture, I mean? &lt;A href="https://twiav.nl/tutorial/arcgis/javascript/arcgis_javascript_example_custom_button.htm" target="_blank" rel="noopener"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-right" image-alt="ArcGIS Maps SDK for JavaScript example: custom button" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62016i62B28299C5548FB9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="arcgis_javascript_example_custom_button.png" alt="ArcGIS Maps SDK for JavaScript example: custom button" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;ArcGIS Maps SDK for JavaScript example: custom button&lt;/span&gt;&lt;/span&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The SDK comes with a load of widgets, all with their own icons, and for your custom buttons there is a whole set of &lt;A href="https://developers.arcgis.com/javascript/latest/esri-icon-font/" target="_blank" rel="noopener"&gt;Esri Icon Fonts (Calcite theme)&lt;/A&gt; available.&lt;/P&gt;&lt;P&gt;But now I want to add my own icon, is that possible? I stumbled into this post &lt;A href="https://community.esri.com/t5/calcite-design-system-questions/use-of-custom-icon/td-p/1169445" target="_blank" rel="noopener"&gt;use of custom icon&lt;/A&gt;, where it was suggested to use &lt;A href="https://developers.arcgis.com/calcite-design-system/components/action/" target="_self"&gt;calcite-action.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;And yeah, with this information I managed to use my own SVG image in a button - see code below.&lt;/P&gt;&lt;P&gt;It is a &lt;A href="https://twiav.nl/tutorial/arcgis/javascript/nederland.svg" target="_self"&gt;huge image&lt;/A&gt; - 924 by 924 pixels! - but because it is a fully Scalable Vector Graphic I can squeeze it down to 25x25px. And to stick with the Esri branded theme I use a fill color of #6e6e6e. In this way it fits in nicely with the rest of the UI.&lt;/P&gt;&lt;P&gt;What do you think?&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Egge-Jan&lt;/P&gt;&lt;P&gt;&lt;A href="https://twiav.nl/tutorial/arcgis/javascript/arcgis_javascript_example_custom_button.htm" target="_blank"&gt;TWIAV | ArcGIS JavaScript example - custom button&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="utf-8"&amp;gt;
  &amp;lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"&amp;gt;
  &amp;lt;title&amp;gt;TWIAV | ArcGIS JavaScript example - custom button&amp;lt;/title&amp;gt;
  &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.25/esri/css/main.css"&amp;gt;
  &amp;lt;script src="https://js.arcgis.com/4.25/"&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;style&amp;gt;
    html, body {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
      font-family: sans-serif;
    }
    #header {	
    	width: 100%;
        height: 70px;
        background-color: #154273;
        color:#FFFFFF;
        margin: 0;
    }
    #headertext {
        float: left;
        font-size: 35px;
        color: white;
        line-height: 70px;
        padding-left: 15px;
    }
    #viewDiv {
        position: absolute;
        top: 70px;
        bottom: 0;
        right: 0;
        left: 0;
        padding: 0;
        margin: 0;
    }
  &amp;lt;/style&amp;gt;
  &amp;lt;script&amp;gt;  
      require([
        "esri/Map",
        "esri/geometry/Point",
        "esri/views/MapView"
      ], function(Map, Point, MapView) {

      const map = new Map({
        basemap: { portalItem: { id: "7aea6fa913a94176a1074edb40690318" } } // Topo RD --&amp;gt; https://www.arcgis.com/home/item.html?id=7aea6fa913a94176a1074edb40690318
      });

      const view = new MapView({
        spatialReference: 28992, 
        container: "viewDiv",
        map: map,
        center: new Point({ x: 145430, y: 427100, spatialReference: 28992 }),
        zoom: 10
      });
      
      view.when(() =&amp;gt; {
        createZoomEntireCountryBtn();
        view.ui.add(["zoomEntireCountryBtn"], "top-left")
      });

      /*******************************************************************************
       * Start zoom to entire country
       *******************************************************************************/
      function createZoomEntireCountryBtn() {
        const zoomEntireCountryBtnDiv = document.createElement('div');
        zoomEntireCountryBtnDiv.innerHTML = `
          &amp;lt;div id="zoomEntireCountryBtn" class="esri-component esri-widget--button esri-widget" role="button"&amp;gt;
            &amp;lt;span title="Zoom uit op heel Nederland"&amp;gt;&amp;lt;calcite-action&amp;gt;&amp;lt;img src="nederland.svg" style="width:25px;height:25px;" alt="nederland"&amp;gt;&amp;lt;/calcite-action&amp;gt;&amp;lt;/span&amp;gt;
          &amp;lt;/div&amp;gt;`;
        document.body.appendChild(zoomEntireCountryBtnDiv);
        document.getElementById("zoomEntireCountryBtn").addEventListener("click", zoomEntireCountry);
      }
      
      function zoomEntireCountry() {
        view.goTo({
          center: new Point({ x: 155000, y: 463000, spatialReference: 28992 }),
          zoom: 3
        });
      }
      /*******************************************************************************
       * End zoom to entire country
       *******************************************************************************/
    });
  &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;div id="header"&amp;gt;
      &amp;lt;div id="headertext" class="stretch"&amp;gt;ArcGIS Maps SDK for JavaScript example: custom button&amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 22:59:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-maps-sdk-for-javascript-example-custom/m-p/1254669#M80149</guid>
      <dc:creator>Egge-Jan_Pollé</dc:creator>
      <dc:date>2023-02-02T22:59:17Z</dc:date>
    </item>
  </channel>
</rss>

