Christian Mayer & Marc Jansen
FOSSGIS 2017, Passau, 23.03.2017
Photo By Jochen Teufel - Own work, CC BY-SA 3.0, Link
GeoExt | ExtJS | OpenLayers |
---|---|---|
1.1.x | 3.4.0 | 2.11.1 |
2.1.x | 4.2.1 / 5.1.0 | 2.13.1 |
3.0.0 | 6.2.0 | 3.20.1 |
3 (master) | 6.2.0 | 4.0.x |
git clone
toolkit
)sencha app watch
& sencha app build
console
beachtenStrategie
view
s, viewmodel
s & controller
ausliefertclassic
wie modern
Ext.Loader
konfigurieren@KaiVolland
&
@marcjansen
Ext.Loader
konfigurieren
Ext.Loader.setConfig({
enabled: true,
paths: {
GeoExt: '../../lib/GeoExt/src',
MyProject: 'http://localhost:3000'
}
});
var express = require('express');
var path = require('path');
var serveStatic = require('serve-static');
var rootDir = path.join(__dirname, '..', '..');
// directories with source code, here for classic
var classicDir = path.normalize(path.join(rootDir, 'classic', 'src'));
var appDir = path.normalize(path.join(rootDir, 'app'));
var classicServer = express(); // Remember to configure CORS
classicServer.use(serveStatic(classicDir));
classicServer.use(serveStatic(appDir));
classicServer.listen(3000);
// same for modern
modern
-Toolkit ignorieren
App-Skeleton erzeugen mit Sencha CMD erzeugen
$ sencha -sdk "/path/to/ext-6.2.0/" generate app MyFirstGeoExtApp MyFirstGeoExtApp
$ cd MyFirstGeoExtApp
$ sencha app watch
In app.json
Property "js" wie folgt erweitern:
"js": [{
"path": "https://openlayers.org/en/v3.20.1/build/ol.js",
"remote": true
}, {
"path": "app.js",
"bundle": true
}],
GeoExt-Sourcen per git beziehen
oder git submodule
$ cd packages
$ git clone https://github.com/geoext/geoext3.git
In app.json
zum "classpath" hinzufügen:
"classpath": [
"app",
"${toolkit.name}/src",
"./packages/geoext3/src"
],
"Standard" ExtJS-View erzeugen
sencha generate view main.Map
Anpassungen erzeugter View (app/view/main/Map.js
):
GeoExt.component.Map
anstelle von Ext.panel.Panel
xtype: 'mappanel'
(Klassenalias)map
(OpenLayers Karte)html
Propertiesapp/view/main/Map.js
Ext.define("MyFirstGeoExtApp.view.main.Map",{
// extend: "Ext.panel.Panel",
extend: "GeoExt.component.Map",
xtype: 'mappanel',
requires: [
"MyFirstGeoExtApp.view.main.MapController",
"MyFirstGeoExtApp.view.main.MapModel"
],
controller: "main-map",
viewModel: {
type: "main-map"
},
// html: "Hello, World!!"
map: new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.Stamen({
layer: 'watercolor'
})
}),
new ol.layer.Tile({
source: new ol.source.Stamen({
layer: 'terrain-labels'
})
})
],
view: new ol.View({
center: ol.proj.fromLonLat( [-8.751278, 40.611368] ),
zoom: 12
})
})
});
In classic/src/view/main/Main.js
und modern/src/view/main/Main.js
folgendes in das Property items
einfügen
{
title: 'GeoExt3 OL3 Map',
iconCls: 'fa-map-marker',
layout: 'fit',
items: [{
xtype: 'mappanel'
}]
}
$ sencha app watch
Diese Folien sind unter CC BY-SA veröffentlicht.