Example of a untiled MapGuide map.
Example of a untiled MapGuide map.
import ImageLayer from 'ol/layer/Image.js';
import ImageMapGuide from 'ol/source/ImageMapGuide.js';
import Map from 'ol/Map.js';
import View from 'ol/View.js';
const mdf = 'Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition';
const agentUrl = 'https://mikenunn.net/mapguide/mapagent/mapagent.fcgi?';
const bounds = [
-87.865114442365922, 43.665065564837931, -87.595394059497067,
43.823852564430069,
];
const map = new Map({
layers: [
new ImageLayer({
extent: bounds,
source: new ImageMapGuide({
projection: 'EPSG:4326',
url: agentUrl,
useOverlay: false,
metersPerUnit: 111319.4908, //value returned from mapguide
params: {
MAPDEFINITION: mdf,
FORMAT: 'PNG',
VERSION: '3.0.0',
USERNAME: 'OLGuest',
PASSWORD: 'olguest',
},
ratio: 2,
}),
}),
],
target: 'map',
view: new View({
center: [-87.7302542509315, 43.744459064634],
projection: 'EPSG:4326',
zoom: 12,
}),
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MapGuide Untiled</title>
<link rel="stylesheet" href="node_modules/ol/ol.css">
<style>
.map {
width: 100%;
height: 400px;
}
</style>
</head>
<body>
<div id="map" class="map"></div>
<script type="module" src="main.js"></script>
</body>
</html>
{
"name": "mapguide-untiled",
"dependencies": {
"ol": "10.3.1"
},
"devDependencies": {
"vite": "^3.2.3"
},
"scripts": {
"start": "vite",
"build": "vite build"
}
}