Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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

Save Automatically?

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>
    <link rel="stylesheet" href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.css" type="text/css" />
      <script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.js"></script>
<body>
  <div id="map"></div>
</body>
</html>
              
            
!

CSS

              
                html,
body {
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
}

#map {
  width: 100%;
  height: 100%;
}

              
            
!

JS

              
                var map = new atlas.Map("map", {
  view: "Auto",
  // Add your Azure Maps subscription client ID to the map SDK.
  authOptions: {
    authType: "anonymous",
    clientId: "04ec075f-3827-4aed-9975-d56301a2d663", // Your Azure Maps account Client ID is required to access your Azure Maps account

    getToken: function (resolve, reject, map) {
      //URL to your authentication service that retrieves an Azure Active Directory Token.
      var tokenServiceUrl = "https://azuremapscodesamples.azurewebsites.net/Common/TokenService.ashx";

      fetch(tokenServiceUrl).then(r => r.text()).then(token => resolve(token));
    }
  }
});

map.events.add("load", function () {

  /* Send a request to Azure Maps search API */
  var url = "https://atlas.microsoft.com/search/fuzzy/json?";
  url += "&api-version=1";
  url += "&query=gasoline%20station";
  url += "&lat=47.6292";
  url += "&lon=-122.2337";
  url += "&radius=100000";

  /* arrays to store bounds and search pins for results */
  var boundsArr = []
  var searchPins = [];

  /* Parse the API response and create a pin on the map for each result */
  /*Process request*/
  fetch(url, {
    headers: {
      "Authorization" : "Bearer " + map.authentication.getToken(),
      "x-ms-client-id" : "35267128-0f1e-41de-aa97-f7a7ec8c2dbd"
    } 
  }).then(function (response) {
    return response.json();
  }).then(function (res) {
    var poiResults =
        res.results.filter(function(result) {
          return result.type === "POI";
        }) || [];
    searchPins = poiResults.map(function(poiResult) {
      var poiPosition = [poiResult.position.lon, poiResult.position.lat];
      boundsArr.push(poiPosition);
      return new atlas.data.Feature(new atlas.data.Point(poiPosition), {
        position: poiResult.position.lat + ", " + poiResult.position.lon
      });
    });

    //Create a data source and add it to the map.
    datasource = new atlas.source.DataSource();
    map.sources.add(datasource);

    var searchLayerName = new atlas.layer.SymbolLayer(datasource, null, {
      iconOptions: {
        iconImage: 'pin-round-darkblue',
        cluster: false,
        allowOverlap: true
      }
    });
    datasource.add(searchPins);
    map.layers.add(searchLayerName);

    var bbox = new atlas.data.BoundingBox.fromLatLngs(boundsArr);

    map.setCamera({
      bounds: bbox, 
      padding: 40
    });
  });
});


              
            
!
999px

Console