Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    />

<title>Earthquakes in the last month</title>

    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
      #séisme {
        color:brown;
      }
    </style>

    <link
      rel="stylesheet"
      href="https://js.arcgis.com/4.12/esri/themes/light/main.css"
    />
    <script src="https://js.arcgis.com/4.12/"></script>
<select id="séisme"></select>
    <script>
      require([
        "esri/Map",
        "esri/layers/GeoJSONLayer",
        "esri/views/MapView"
      ], function(Map, GeoJSONLayer, MapView) {

        // Paste the url into a browser's address bar to download and view the attributes
        // in the GeoJSON file. These attributes include:
        // * mag - magnitude
        // * type - earthquake or other event such as nuclear test
        // * place - location of the event
        // * time - the time of the event
        // Use the Arcade Date() function to format time field into a human-readable format

        const template = {
          title: "Info séisme",
          content: "Magnitude {mag} {type} a frappé {place} le {time}",
          fieldInfos: [
            {
              fieldName: "time",
              format: {
                dateFormat: "short-date-short-time"
              }
            }
          ]
        };

        //size of points depends on the magnitude
        const renderer = {
          type: "simple",
          field: "mag",
          symbol: {
            type: "simple-marker",
            color: "orange",
            outline: {
              color: "white"
            }
          },
          visualVariables: [
            {
              type: "size",
              field: "mag",
              stops: [
                {
                  value: 2.5,
                  size: "4px"
                },
                {
                  value: 8,
                  size: "40px"
                }
              ]
            }
          ]
        };

        //load a first layer
        const geojsonLayer = new GeoJSONLayer({
          url: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson",
          renderer: renderer, //optional
          popupTemplate:template
        });

        const map = new Map({
          basemap: "oceans",
          layers: [geojsonLayer]
        });

        const view = new MapView({
          container: "viewDiv",
          center: [2.3488, 48.8534],
          zoom: 3,
          map: map
        });
        // create a dropdown list with several options to see more or less recent earthquakes
      let séisme=document.getElementById("séisme");
      
        let option1=document.createElement("option");
     option1.textContent="all_month.geojson";
      séisme.appendChild(option1);
        
     let option2=document.createElement("option");
     option2.textContent="all_week.geojson";
      séisme.appendChild(option2);
        
      let option3=document.createElement("option");
      option3.textContent="all_day.geojson";
      séisme.appendChild(option3);
        
      let option4=document.createElement("option");
      option4.textContent="all_hour.geojson";
      séisme.appendChild(option4);
 view.ui.add(séisme, "top-right"); //position the dropdown list at the top-right       
    // define the event when we change the earthquake in the dropdown list, the map is updated with the new layer
séisme.addEventListener("change",function(){
  let selectedService=séisme.options[séisme.selectedIndex].textContent;
        let layer = new GeoJSONLayer({
          url:"https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/" +selectedService,
          renderer:renderer,
          popupTemplate:template,
        })
        map.removeAll(); //don't have too much layers loaded
        map.add(layer);

      })
  
      });

    </script>
  </head>

  <body>
    <div id="viewDiv"></div>
  </body>
</html>

              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console