Ich bin neu bei node.js und versuche, eine einfache OpenLayers-Map auf eine Seite zu stellen. Die Karte wird jedoch nicht angezeigt.Eine OpenLayers-Map in Node.js erstellen View
Code:
app.js
var express = require('express');
var app = express();
app.set('view engine', 'jade');
app.use(express.static(__dirname + '/public'));
app.get('/', function(req, res){
res.render('index', {title: 'Map Viewer'});
});
app.get('/map', function(req, res){
res.render('view');
});
app.listen(3000, function(){
console.log('Server listening on port 3000...');
});
layout.jade
doctype html
html
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
body
block content
view.jade
extends layout
block content
#map
script(type='text/javascript').
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
title: 'Global Imagery',
source: new ol.source.TileWMS({
url: 'http://demo.opengeo.org/geoserver/wms',
params: {LAYERS: 'nasa:bluemarble', VERSION: '1.1.1'}
})
})
],
view: new ol.View({
projection: 'EPSG:4326',
center: [0, 0],
zoom: 0,
maxResolution: 0.703125
})
});
In package.json
Ich verwende "openlayers": "^3.15.1"
Ergebnis:
Der obige Code eine leere Seite mit dem folgenden HTML produziert:
<html>
<head>
</head>
<title>
</title>
<link rel="stylesheet" href="/stylesheets/style.css">
<body>
<div id="map">
</div>
</body>
</html>
Irgendeine Idee wh bei mir mache ich falsch?