|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width"> |
| 6 | + <title>MapServer CGI</title> |
| 7 | + <link rel=" stylesheet" type=" text/css" href=" https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" crossorigin=" anonymous" > |
| 8 | + <link rel=" stylesheet" type=" text/css" href=" https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/fontawesome.min.css" crossorigin=" anonymous" > |
| 9 | + <link rel=" stylesheet" type=" text/css" href=" https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/solid.css" crossorigin=" anonymous" > |
| 10 | + <link rel=" stylesheet" type=" text/css" href=" https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/brands.css" crossorigin=" anonymous" > |
| 11 | + <link rel="stylesheet" type="text/css" href="./theme/ol.css"> |
| 12 | + <link rel="stylesheet" type="text/css" href="/theme/site.css"> |
| 13 | + <link rel="icon" type="image/svg+xml" href="/theme/img/logo-light.svg" media="(prefers-color-scheme: light)" /> |
| 14 | + <link rel="icon" type="image/svg+xml" href="/theme/img/logo-dark.svg" media="(prefers-color-scheme: dark)" /> |
| 15 | + </head> |
| 16 | + <body> |
| 17 | + <header class="navbar navbar-expand-md navbar-dark mb-3 px-3 py-0 fixed-top" role="navigation"> |
| 18 | + <a class="navbar-brand" href="/"><img src="/theme/img/logo-dark.svg" width="70" height="70" alt=""> OpenLayers</a> |
| 19 | + <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#olmenu" aria-controls="olmenu" aria-expanded="false" aria-label="Toggle navigation"> |
| 20 | + <span class="navbar-toggler-icon"></span> |
| 21 | + </button> |
| 22 | + |
| 23 | + <!-- menu items that get hidden below 768px width --> |
| 24 | + <nav class="collapse navbar-collapse" id="olmenu"> |
| 25 | + <ul class="nav navbar-nav ms-auto"> |
| 26 | + <li class="nav-item dropdown"> |
| 27 | + <a class="nav-link dropdown-toggle" href="#" id="docdropdown" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Docs</a> |
| 28 | + <div class="dropdown-menu dropdown-menu-end mb-3" aria-labelledby="docdropdown"> |
| 29 | + <a class="dropdown-item" href="/doc/">Docs</a> |
| 30 | + <div class="dropdown-divider"></div> |
| 31 | + <a class="dropdown-item" href="/doc/quickstart.html"><i class="fa fa-check fa-fw me-2 fa-lg"></i>Quick Start</a> |
| 32 | + <a class="dropdown-item" href="/doc/faq.html"><i class="fa fa-question fa-fw me-2 fa-lg"></i>FAQ</a> |
| 33 | + <a class="dropdown-item" href="/doc/tutorials/"><i class="fa fa-book fa-fw me-2 fa-lg"></i>Tutorials</a> |
| 34 | + <a class="dropdown-item" href="/workshop/"><i class="fa fa-graduation-cap fa-fw me-2 fa-lg"></i>Workshop</a> |
| 35 | + <div class="dropdown-divider"></div> |
| 36 | + <a class="dropdown-item" href="https://stackoverflow.com/questions/tagged/openlayers"><i class="fab fa-stack-overflow fa-fw me-2"></i>Ask a Question</a> |
| 37 | + </div> |
| 38 | + </li> |
| 39 | + <li class="nav-item"><a class="nav-link" href="../examples/">Examples</a></li> |
| 40 | + <li class="nav-item"><a class="nav-link" href="../apidoc/"><i class="fa fa-sitemap me-1"></i>API</a></li> |
| 41 | + <li class="nav-item dropdown"> |
| 42 | + <a class="nav-link dropdown-toggle" href="#" id="codedropdown" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Code</a> |
| 43 | + <div class="dropdown-menu dropdown-menu-end mb-3" aria-labelledby="codedropdown"> |
| 44 | + <a class="dropdown-item" href="https://github.com/openlayers/openlayers"><i class="fab fa-github fa-fw me-2 fa-lg"></i>Repository</a> |
| 45 | + <a class="dropdown-item" href="/download/"><i class="fa fa-download fa-fw me-2 fa-lg"></i>Download</a> |
| 46 | + </div> |
| 47 | + </li> |
| 48 | + </ul> |
| 49 | + </nav> |
| 50 | + </header> |
| 51 | + |
| 52 | + <div class="container-fluid line-numbers"> |
| 53 | + <div id="latest-check" class="alert alert-warning alert-dismissible" role="alert" style="display:none"> |
| 54 | + <button id="latest-dismiss" type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> |
| 55 | + This example uses OpenLayers v<span>10.3.2-dev</span>. The <a id="latest-link" href="#" class="alert-link">latest</a> is v<span id="latest-version"></span>. |
| 56 | + </div> |
| 57 | + |
| 58 | + |
| 59 | + <div class="row-fluid"> |
| 60 | + <a href="#" id="codepen-button" class="btn btn-link float-end"> |
| 61 | + <i class="fab fa-codepen fa-lg"></i> Edit |
| 62 | + </a> |
| 63 | + <h4 id="title">MapServer CGI</h4> |
| 64 | + <p class="tags"> |
| 65 | + <span class="badge-group"> |
| 66 | + <a |
| 67 | + href="./index.html?q=mapserver" class="badge badge-info">mapserver</a |
| 68 | + ><a |
| 69 | + class="badge badge-info tag-modal-toggle" |
| 70 | + data-bs-toggle="modal" |
| 71 | + data-bs-target="#tag-example-list" |
| 72 | + data-title="mapserver" |
| 73 | + data-content="<ul class="list-group"> |
| 74 | + <li><a class="list-group-item list-group-item-action active" href="./mapserver-cgi.html">MapServer CGI</a> |
| 75 | + </ul>" |
| 76 | + tabindex="0" |
| 77 | + >1</a> |
| 78 | + </span> |
| 79 | + <span class="badge-group"> |
| 80 | + <a |
| 81 | + href="./index.html?q=cgi" class="badge badge-info">cgi</a |
| 82 | + ><a |
| 83 | + class="badge badge-info tag-modal-toggle" |
| 84 | + data-bs-toggle="modal" |
| 85 | + data-bs-target="#tag-example-list" |
| 86 | + data-title="cgi" |
| 87 | + data-content="<ul class="list-group"> |
| 88 | + <li><a class="list-group-item list-group-item-action active" href="./mapserver-cgi.html">MapServer CGI</a> |
| 89 | + </ul>" |
| 90 | + tabindex="0" |
| 91 | + >1</a> |
| 92 | + </span> |
| 93 | + </p> |
| 94 | + <div class="modal modal-tag-example" id="tag-example-list" tabindex="-1" role="dialog" aria-labelledby="tag-example-title" aria-hidden="true"> |
| 95 | + <div class="modal-dialog modal-dialog-scrollable" role="document"> |
| 96 | + <div class="modal-content"> |
| 97 | + <div class="modal-header"> |
| 98 | + <h5 class="modal-title" id="tag-example-title"></h5> |
| 99 | + <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
| 100 | + </div> |
| 101 | + <div class="modal-body"> |
| 102 | + <div class="list-group"></div> |
| 103 | + </div> |
| 104 | + </div> |
| 105 | + </div> |
| 106 | + </div> |
| 107 | + <div id="map" class="map"></div> |
| 108 | + |
| 109 | + <form method="POST" id="codepen-form" target="_blank" action="https://codesandbox.io/api/v1/sandboxes/define"> |
| 110 | + <input id="codesandbox-params" type="hidden" name="parameters"> |
| 111 | + </form> |
| 112 | + </div> |
| 113 | + |
| 114 | + <div class="row-fluid"> |
| 115 | + <p id="shortdesc">Example of a MapServer CGI map.</p> |
| 116 | + <div id="docs"><p>Example of a map generated using the MapServer <a href="https://mapserver.org/cgi/controls.html">CGI Controls</a>. The CGI interface allows testing a Mapfile without having to configure WMS services. The Mapfile used in this example can be seen <a href="https://demo.mapserver.org/itasca_legend/itasca3.txt">here</a>. |
| 117 | +It is <strong>strongly</strong> recommended to configure MapServer to serve WMS and use the OpenLayers WMS loader, rather than this older CGI approach.</p> |
| 118 | +</div> |
| 119 | + </div> |
| 120 | + |
| 121 | + <div class="row-fluid"> |
| 122 | + <h5 class="source-heading">main.js</h5> |
| 123 | + <pre><code id="example-js-source" class="language-js">import Map from 'ol/Map.js'; |
| 124 | +import View from 'ol/View.js'; |
| 125 | +import {getCenter} from 'ol/extent.js'; |
| 126 | +import ImageLayer from 'ol/layer/Image.js'; |
| 127 | +import ImageSource from 'ol/source/Image.js'; |
| 128 | +import {createLoader} from 'ol/source/mapserver.js'; |
| 129 | + |
| 130 | +const mapserverUrl = 'https://demo.mapserver.org/cgi-bin/mapserv?'; |
| 131 | +const bounds = [388039, 5234969, 500964, 5295764]; |
| 132 | +const mapServerLayer = new ImageLayer({ |
| 133 | + extent: bounds, |
| 134 | + source: new ImageSource({ |
| 135 | + loader: createLoader({ |
| 136 | + url: mapserverUrl, |
| 137 | + params: { |
| 138 | + 'map': '/mapserver/apps/itasca_legend/map/itasca3.map', |
| 139 | + 'layers': 'boundaries water roads other cities', |
| 140 | + }, |
| 141 | + }), |
| 142 | + }), |
| 143 | +}); |
| 144 | + |
| 145 | +const map = new Map({ |
| 146 | + layers: [mapServerLayer], |
| 147 | + target: 'map', |
| 148 | + view: new View({ |
| 149 | + center: getCenter(bounds), |
| 150 | + zoom: 10, |
| 151 | + }), |
| 152 | +}); |
| 153 | +</code></pre> |
| 154 | + </div> |
| 155 | + |
| 156 | + <div class="row-fluid"> |
| 157 | + <h5 class="source-heading">index.html</h5> |
| 158 | + <pre><code id="example-html-source" class="language-markup"><!DOCTYPE html> |
| 159 | +<html lang="en"> |
| 160 | + <head> |
| 161 | + <meta charset="UTF-8"> |
| 162 | + <title>MapServer CGI</title> |
| 163 | + <link rel="stylesheet" href="node_modules/ol/ol.css"> |
| 164 | + <style> |
| 165 | + .map { |
| 166 | + width: 100%; |
| 167 | + height: 400px; |
| 168 | + } |
| 169 | + </style> |
| 170 | + </head> |
| 171 | + <body> |
| 172 | + <div id="map" class="map"></div> |
| 173 | + |
| 174 | + <script type="module" src="main.js"></script> |
| 175 | + </body> |
| 176 | +</html></code></pre> |
| 177 | + </div> |
| 178 | + |
| 179 | + <div class="row-fluid"> |
| 180 | + <h5 class="source-heading">package.json</h5> |
| 181 | + <pre><code id="example-pkg-source" class="language-json">{ |
| 182 | + "name": "mapserver-cgi", |
| 183 | + "dependencies": { |
| 184 | + "ol": "10.3.2-dev" |
| 185 | + }, |
| 186 | + "devDependencies": { |
| 187 | + "vite": "^3.2.3" |
| 188 | + }, |
| 189 | + "scripts": { |
| 190 | + "start": "vite", |
| 191 | + "build": "vite build" |
| 192 | + } |
| 193 | +}</code></pre> |
| 194 | + </div> |
| 195 | + </div> |
| 196 | + |
| 197 | + <script src=" https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" ></script> |
| 198 | + <script src="common.js"></script> |
| 199 | + <script src="mapserver-cgi.js"></script> |
| 200 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.28.0/components/prism-core.min.js"></script> |
| 201 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.28.0/plugins/autoloader/prism-autoloader.min.js"></script> |
| 202 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.28.0/plugins/toolbar/prism-toolbar.min.js"></script> |
| 203 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.28.0/plugins/copy-to-clipboard/prism-copy-to-clipboard.js"></script> |
| 204 | + <script src="./resources/common.js"></script> |
| 205 | + <script> |
| 206 | + document.getElementById('tag-example-list') |
| 207 | + .addEventListener('show.bs.modal', function (event) { |
| 208 | + const button = event.relatedTarget; // Button that triggered the modal |
| 209 | + this.querySelector('.modal-title').innerText = button.dataset.title; |
| 210 | + this.querySelector('.modal-body').innerHTML = button.dataset.content; |
| 211 | + }); |
| 212 | + </script> |
| 213 | + <script> |
| 214 | + const releaseUrl = 'https://cdn.jsdelivr.net/npm/ol/package.json'; |
| 215 | + fetch(releaseUrl).then(function(response) { |
| 216 | + return response.json(); |
| 217 | + }).then(function(json) { |
| 218 | + const latestVersion = json.version; |
| 219 | + document.getElementById('latest-version').innerHTML = latestVersion; |
| 220 | + const url = window.location.href; |
| 221 | + const branchSearch = url.match(/\/([^\/]*)\/examples\//); |
| 222 | + const storageKey = 'ol-dismissed=-' + latestVersion; |
| 223 | + const dismissed = localStorage.getItem(storageKey) === 'true'; |
| 224 | + if (branchSearch && !dismissed && /^v[0-9\.]*$/.test(branchSearch[1]) && '10.3.2-dev' != latestVersion) { |
| 225 | + const link = url.replace(branchSearch[0], '/latest/examples/'); |
| 226 | + fetch(link, {method: 'head'}).then(function(response) { |
| 227 | + const a = document.getElementById('latest-link'); |
| 228 | + a.href = response.status == 200 ? link : '../../latest/examples/'; |
| 229 | + }); |
| 230 | + const latestCheck = document.getElementById('latest-check'); |
| 231 | + latestCheck.style.display = ''; |
| 232 | + document.getElementById('latest-dismiss').onclick = function() { |
| 233 | + latestCheck.style.display = 'none'; |
| 234 | + localStorage.setItem(storageKey, 'true'); |
| 235 | + } |
| 236 | + } |
| 237 | + }); |
| 238 | + </script> |
| 239 | + </body> |
| 240 | +</html> |
0 commit comments