Beginner help with webmap

257
1
11-07-2018 12:22 PM
TonyFarrell
New Contributor

Pretty new to the webmap side of ESRI - please be patient.

I have created a basic WebMap and it is displaying in one of my web pages.

Now i need to extend the functionality.

Task 1 - Implement a search and center on an address that the user will enter.

Task 2 - Place dynamic markers on the map and erase them.

Here is my starter code

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  <title>Load a basic WebMap - 4.9</title>
  <style>

    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }
  </style>
  <link rel="stylesheet" href="css/esriStyles.css">
  <link rel="stylesheet" href="https://js.arcgis.com/4.9/esri/css/main.css">
  <script src="https://js.arcgis.com/4.9/"></script>
  <script>
    require([
      "esri/views/MapView",
      "esri/WebMap"
    ], function (
      MapView,
      WebMap
    ) {

        /************************************************************
         * Creates a new WebMap instance. A WebMap must reference
         * a PortalItem ID that represents a WebMap saved to
         * arcgis.com or an on-premise portal.
         *
         * To load a WebMap from an on-premise portal, set the portal
         * url with esriConfig.portalUrl.
         ************************************************************/
        var webmap = new WebMap({
          portalItem: { // autocasts as new PortalItem()
            id: "52a26407bcb244ac9a29acf64aab4d0b"
          }
        });


        /************************************************************
         * Set the WebMap instance to the map property in a MapView.
         ************************************************************/
        var view = new MapView({
          map: webmap,
          container: "viewDiv"
        });

      });
  </script>
</head>
<body>
  <div class="loading-indicator" role="presentation">
    <div class="loading-message" id="loading_message"></div>
  </div>
  <div id="viewDiv"></div>
</body>
</html>

0 Kudos
1 Reply
Noah-Sager
Esri Regular Contributor

Here is an example of the functionality that you are looking for I think:

WebMap+ 

It combines these 3 sample:

Load a basic WebMap | ArcGIS API for JavaScript 4.9 

Search Widget | ArcGIS API for JavaScript 4.9 

Sketch temporary geometries | ArcGIS API for JavaScript 4.9 

Hope this helps.