# WMS

Raster map images over the OGC Web Map Service 1.3.0, for any GIS client or map library.

## Add it to your application

Raster map images over the OGC Web Map Service, drawn in your browser by the BeMap JS API on Leaflet or OpenLayers, from the geoservers your account provides. The page draws this map live with your own account.

With the BeMap JS API 2.0.4, the release the page's live map runs, or with the library you already use. Replace `YOUR_ACCOUNT`, `YOUR_API_KEY` and `YOUR_GEOSERVER` with your own.

### BeMap JS API · Leaflet

```html
<!-- The BeMap JS API and the engine it drives -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/BeNomadSAS/bemap-js-api@2.0.4/dist/leaflet.css" integrity="sha256-M3v8pcq9A7OYFbJwD+vis7ft9VkhxZzUn4jssyghIwM=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/BeNomadSAS/bemap-js-api@2.0.4/dist/bemap-js-api.css" integrity="sha256-6JTuf+5yR2uKDbRMVCKVkicMghqX/fopHJUUH0a9IwE=" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/gh/BeNomadSAS/bemap-js-api@2.0.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/gh/BeNomadSAS/bemap-js-api@2.0.4/dist/bemap-js-api.min.js" integrity="sha256-9nw1Dpfl6zDEakYlPDODJHrz9RvsqjZ+HttOFJNJMss=" crossorigin="anonymous"></script>

<div id="map" style="height: 480px"></div>
<script>
  var ctx = new bemap.Context({
    host: 'bemap.benomad.com', secure: true,
    login: 'YOUR_ACCOUNT', password: 'YOUR_API_KEY', // for evaluation: in production, use the proxy option
    // Leaflet needs the geoserver named: one of your account's that draws maps
    // (new bemap.AclService(ctx).getCurrentUserDetails() lists your account's).
    geoserver: 'YOUR_GEOSERVER'
  });
  new bemap.LeafletMap(ctx, 'map').defaultLayers().move(2.35, 48.85, 12);
</script>
```

### BeMap JS API · OpenLayers

```html
<!-- The BeMap JS API and the engine it drives -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/BeNomadSAS/bemap-js-api@2.0.4/dist/ol.css" integrity="sha256-q8iv1yzBC9KcwUP0Q7rkpoBL08s/smLmtqa8bJJOo08=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/BeNomadSAS/bemap-js-api@2.0.4/dist/bemap-js-api.css" integrity="sha256-6JTuf+5yR2uKDbRMVCKVkicMghqX/fopHJUUH0a9IwE=" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/gh/BeNomadSAS/bemap-js-api@2.0.4/dist/ol.js" integrity="sha256-Dcmd21j13KXnaK0AJdTIZCvP9hb46nhNtYAdlq3f63o=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/gh/BeNomadSAS/bemap-js-api@2.0.4/dist/bemap-js-api.min.js" integrity="sha256-9nw1Dpfl6zDEakYlPDODJHrz9RvsqjZ+HttOFJNJMss=" crossorigin="anonymous"></script>

<div id="map" style="height: 480px"></div>
<script>
  var ctx = new bemap.Context({
    host: 'bemap.benomad.com', secure: true,
    login: 'YOUR_ACCOUNT', password: 'YOUR_API_KEY' // for evaluation: in production, use the proxy option
  });
  new bemap.OlMap(ctx, 'map').defaultLayers().move(2.35, 48.85, 12);
</script>
```

### Leaflet

```javascript
// Leaflet alone. A map tile is an image and cannot carry an Authorization
// header, so BeMap's WMS also reads the account from appid and appcode, a
// way BeMap deprecates: for evaluation only. In production, serve the tiles
// through your own server, which adds the header, or use the BeMap JS API's
// proxy option (the JS API tabs).
const map = L.map('map').setView([48.85, 2.35], 12);
L.tileLayer.wms('https://bemap.benomad.com/bgis/wms', {
  layers: 'default',
  format: 'image/png',
  version: '1.1.1',
  appid: 'YOUR_ACCOUNT',
  appcode: 'YOUR_API_KEY', // for evaluation: in production, serve the tiles through your own server
}).addTo(map);
```

### curl

```bash
# One map image, 800 x 600, over central Paris.
# WMS 1.3.0 with EPSG:4326 reads BBOX latitude first: minLat,minLon,maxLat,maxLon
curl -s -o paris.png -u 'YOUR_ACCOUNT:YOUR_API_KEY' \
  'https://bemap.benomad.com/bgis/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&LAYERS=&STYLES=&CRS=EPSG:4326&BBOX=48.80,2.25,48.91,2.42&WIDTH=800&HEIGHT=600&FORMAT=image/png'

# A failure also answers 200, with an XML exception instead of an image:
# check the Content-Type, not the status.
```

### QGIS

```
QGIS: Layer › Add Layer › Add WMS/WMTS Layer…

1. New connection
     Name            BeMap
     URL             https://bemap.benomad.com/bgis/wms
     Authentication  Basic, with your BeMap account and API key
2. Connect, then add the layer the server lists.
3. Coordinate reference system: EPSG:4326 or EPSG:3857.
```

## Tutorials

- [Get a satellite image with WMS 1.3.0](https://benomad.com/dev/doc/bemap-api/guides/maps/mapping-wms-1-3-0-satellite.md)

## Guides

- [GetMap service · 1.3.0](https://benomad.com/dev/doc/bemap-api/api/map-rendering/mapping-wms-1-3-0-getmap.md)
- [GetCapabilities service · 1.3.0](https://benomad.com/dev/doc/bemap-api/api/map-rendering/mapping-wms-1-3-0-getcapabilities.md)

## With the BeMap JS API

- [Basic map](https://benomadsas.github.io/bemap-js-api/examples/index.html#nav-example-00.html): runs live in the JS API gallery
- [Clustering (Leaflet, with shapes)](https://benomadsas.github.io/bemap-js-api/examples/index.html#nav-example-leaflet-00.html): runs live in the JS API gallery
