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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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>
<script src="https://atlas.microsoft.com/sdk/javascript/spatial/0/atlas-spatial.min.js"></script>

<body>
    <div class='sidePanel'>
      <b>WFS Filters</b><br/><br/>
      
        <input type="button" value="Get first 500" onclick="getFirst500()" /><br/>

        <input type="button" value="Get second 500" onclick="getFirst500()" /><br/>

        <input type="button" value="ID filter" onclick="idFilter()" /><br/><br/>
      
        <input type="button" value="Logic based filter" onclick="propertyFilter1()" /><br/>

        <input type="button" value="Multiple property value filters" onclick="propertyFilter2()" /><br/>

        <input type="button" value="Value is within a range filter" onclick="propertyFilter3()" /><br/>

        <input type="button" value="Property value filter" onclick="propertyFilter4()" /><br/><br/>

        <input type="button" value="BBox filter" onclick="bboxFilter1()" /><br/><br/>

        <input type="button" value="CQL filter" onclick="cqlFilter()" /><br/>

        <input type="button" value="Custom filter" onclick="customFilter()" />
  </div>
  
    <div id="map"></div>
</body>

</html>
              
            
!

CSS

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

#map {
  position: relative;
  width:calc(100% - 220px);
  height:100%;
  float:left;
}

.sidePanel {
  position: relative;
  width:200px;
  margin:10px;
  float:left;
}
 
              
            
!

JS

              
                //Initialize a map instance.
var map = new atlas.Map('map', {
    view: "Auto",
    //Add your Azure Maps subscription client ID to the map SDK. Get an Azure Maps client ID at https://azure.com/maps
    authOptions: {
        authType: "anonymous",
        clientId: "35267128-0f1e-41de-aa97-f7a7ec8c2dbd",
        getToken: function(resolve, reject, map) {
          //URL to your authentication service that retrieves an Azure Active Directory Token.
          var tokenServiceUrl = "https://adtokens.azurewebsites.net/api/HttpTrigger1?code=dv9Xz4tZQthdufbocOV9RLaaUhQoegXQJSeQQckm6DZyG/1ymppSoQ==";

          fetch(tokenServiceUrl).then(r => r.text()).then(token => resolve(token));
        }
    }
});
var client, capabilities, layer, f;
//Create the WFS client to access the service. 
client = new atlas.io.ogc.WfsClient({
    url: 'https://giswebservices.massgis.state.ma.us/geoserver/wfs?request=GetCapabilities&service=WFS'
});
//Check the capabilities of the service.
client.getCapabilities().then(cap => {
    capabilities = cap;
});
//Wait until the map resources are ready.
map.events.add('ready', function() {
    //Cache a reference to the filters namespace for shorter filter creation code later.
    f = atlas.io.ogc.filter;
    //Create a data source and add it to the map.
    datasource = new atlas.source.DataSource();
    map.sources.add(datasource);
    //Add a simple data layer for rendering the data.
    layer = new atlas.layer.SimpleDataLayer(datasource);
    map.layers.add(layer);
});

function getFirst500() {
    //Retrieve the first 500 results.
    processQuery({
        typeNames: 'massgis:GISDATA.CENSUS1990BLOCKGROUPS_POLY',
        count: 500
    });
}

function getNext500() {
    //Page to the next 500 results.
    processQuery({
        typeNames: 'massgis:GISDATA.CENSUS1990BLOCKGROUPS_POLY',
        count: 500,
        startIndex: 500
    });
}

function idFilter() {
    //Get feature by ID.
    processQuery({
        typeNames: 'massgis:GISDATA.CENSUS1990BLOCKGROUPS_POLY',
        featureId: 'GISDATA.CENSUS1990BLOCKGROUPS_POLY.4389'
    });
}

function propertyFilter1() {
    //Logic based filter: if(pop100/1000 > 2 && households >= 500)
    processQuery({
        typeNames: 'massgis:GISDATA.CENSUS1990BLOCKGROUPS_POLY',
        filter: new f.And(
            new f.IsGreaterThan(new f.Div(new f.PropertyName('pop100'), 1000), 2),
            new f.IsGreaterThanOrEqual(new f.PropertyName('households'), 500)
        )
    });
}

function propertyFilter2() {
    //Multiple property value filters.
    //https://wiki.state.ma.us/display/massgis/GeoServer+-+WFS+-+Filter+-+Get+Subset+of+Attribute+Values+for+a+Feature+-+Complex+Filter
    processQuery({
        typeNames: 'massgis:GISDATA.SCHOOLS_PT',
        filter: new f.And(
            new f.IsEqual(new f.PropertyName('type'), 'CHA'),
            new f.IsEqual(new f.PropertyName('town'), 'SPRINGFIELD'),
            new f.IsLike(new f.PropertyName('grades'), '*K*'),
            new f.IsLike(new f.PropertyName('grades'), '*12*')
        )
    });
}

function propertyFilter3() {
    //Value is within a range filter.
    //https://wiki.state.ma.us/display/massgis/GeoServer+-+WFS+-+Filter+-+PropertyIsBetween
    processQuery({
        typeNames: 'massgis:GISDATA.TOWNS_POLYM',
        filter: new f.IsBetween(new f.PropertyName('pop2000'), 5000, 6000)
    });
}

function propertyFilter4() {
    //Property value filter.
    //https://wiki.state.ma.us/display/massgis/GeoServer+-+WFS+-+Get+Shape+Coordinates+for+Feature
    processQuery({
        typeNames: 'massgis:GISDATA.TOWNS_POLY',
        propertyName: 'shape',
        filter: new f.IsEqual(new f.PropertyName('town'), 'HANCOCK')
    });
}

function bboxFilter1() {
    //Bounding box filter.
    processQuery({
        typeNames: 'massgis:GISDATA.CENSUS1990BLOCKGROUPS_POLY',
        bbox: [-71.16686, 42.35918, -71.03708, 42.420035]
    });
}

function cqlFilter() {
    //A CQL filter.
    processQuery({
        typeNames: 'massgis:GISDATA.SCHOOLS_PT',
        cql_filter: "BBOX(shape,45004,909195,55684,932912)"
    });
}

function customFilter() {
    //A custom XML filter.
    processQuery({
        typeNames: 'massgis:GISDATA.TOWNS_POLY',
        filter: new f.CustomFilter('<Filter><PropertyIsEqualTo><PropertyName>town</PropertyName><Literal>HANCOCK</Literal></PropertyIsEqualTo></Filter>')
    });
}

function processQuery(featureRequest) {
    datasource.clear();
    //Request features using the filtered request.
    client.getFeatures(featureRequest).then(fc => {
        if (fc) {
            //Set the view of the map over the data.
            if (fc.bbox) {
                map.setCamera({
                    bounds: fc.bbox,
                    padding: 50
                });
            }
            //Update data in the data source.
            datasource.setShapes(fc);
        }
    }, error => {
        alert(error);
    });
}
              
            
!
999px

Console