gwt: add vtm-web-js project
This commit is contained in:
parent
e6eab7f773
commit
c7508d330d
settings.gradle
vtm-web-js
vtm-web/src/org/oscim/gdx/client
@ -10,6 +10,7 @@ include ':vtm-desktop'
|
||||
include ':vtm-android-gdx'
|
||||
include ':vtm-web'
|
||||
include ':vtm-web-app'
|
||||
include ':vtm-web-js'
|
||||
include ':vtm-ios'
|
||||
include ':vtm-jeo'
|
||||
include ':vtm-jeo-desktop'
|
||||
|
7
vtm-web-js/.gitignore
vendored
Normal file
7
vtm-web-js/.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
src/main/webapp/
|
||||
war/VtmWebApp/
|
||||
war/assets/
|
||||
war/WEB-INF/
|
||||
assets/
|
||||
gwt-unitCache/
|
||||
build/
|
106
vtm-web-js/build.gradle
Normal file
106
vtm-web-js/build.gradle
Normal file
@ -0,0 +1,106 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven { url 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/' }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.3'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||
}
|
||||
|
||||
apply plugin: 'war'
|
||||
apply plugin: 'jetty'
|
||||
apply plugin: 'gwt'
|
||||
apply plugin: 'eclipse'
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs = ['src']
|
||||
}
|
||||
|
||||
dependencies {
|
||||
providedCompile project(':vtm-web')
|
||||
providedCompile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
|
||||
providedCompile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
|
||||
providedCompile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
|
||||
providedCompile 'ru.finam:slf4j-gwt:1.2.1'
|
||||
providedCompile 'org.slf4j:slf4j-api:1.7.5'
|
||||
providedCompile 'org.timepedia.exporter:gwtexporter:2.5.0-SNAPSHOT'
|
||||
}
|
||||
|
||||
// explicit dependencies for org.gradle.configureondemand=true
|
||||
evaluationDependsOn(':vtm')
|
||||
evaluationDependsOn(':vtm-themes')
|
||||
evaluationDependsOn(':vtm-gdx')
|
||||
evaluationDependsOn(':vtm-web')
|
||||
|
||||
gwt {
|
||||
gwtVersion='2.6.0'
|
||||
modules 'org.oscim.web.VtmWebJs'
|
||||
|
||||
superDev {
|
||||
noPrecompile=true
|
||||
}
|
||||
compiler {
|
||||
enableClosureCompiler = false; // activates -XenableClosureCompiler
|
||||
disableClassMetadata = true; // activates -XdisableClassMetadata
|
||||
disableCastChecking = true; // activates -XdisableCastChecking
|
||||
}
|
||||
|
||||
src += files(sourceSets.main.java.srcDirs)
|
||||
src += files(project(':vtm').sourceSets.main.allJava.srcDirs)
|
||||
src += files(project(':vtm-themes').sourceSets.main.allJava.srcDirs)
|
||||
src += files(project(':vtm-themes').sourceSets.main.resources.srcDirs)
|
||||
src += files(project(':vtm-gdx').sourceSets.main.allJava.srcDirs)
|
||||
src += files(project(':vtm-web').sourceSets.main.allJava.srcDirs)
|
||||
}
|
||||
|
||||
// Run jetty with draft compiled war
|
||||
task jettyDraftWar(type: JettyRunWar) {
|
||||
dependsOn draftWar
|
||||
dependsOn.remove('war')
|
||||
webApp=draftWar.archivePath
|
||||
}
|
||||
|
||||
task copyThemeAssets(type: Copy) {
|
||||
from "$rootDir/vtm-themes/resources/assets"
|
||||
into "assets"
|
||||
include '**/*'
|
||||
}
|
||||
|
||||
task copyVtmAssets(type: Copy) {
|
||||
from "$rootDir/vtm/resources/assets"
|
||||
into "assets"
|
||||
include '**/*'
|
||||
}
|
||||
|
||||
task copyWarSources(type: Copy) {
|
||||
from 'war/index.html'
|
||||
from 'war/default.css'
|
||||
from 'war/map.js'
|
||||
into "src/main/webapp"
|
||||
//include '**/*'
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) { compileTask ->
|
||||
compileTask.dependsOn copyThemeAssets
|
||||
compileTask.dependsOn copyVtmAssets
|
||||
compileTask.dependsOn copyWarSources
|
||||
}
|
||||
|
||||
// Configuring Eclipse classpath
|
||||
eclipse.classpath {
|
||||
|
||||
defaultOutputDir = file('war/WEB-INF/classes')
|
||||
|
||||
//file {
|
||||
// whenMerged { classpath ->
|
||||
// classpath.entries.findAll { entry ->
|
||||
// entry.path == 'src' }*.excludes = ['main','org/oscim/gdx/emu/']
|
||||
// }
|
||||
//}
|
||||
}
|
10
vtm-web-js/src/main/webapp/WEB-INF/web.xml
Normal file
10
vtm-web-js/src/main/webapp/WEB-INF/web.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
||||
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
|
||||
<!-- TODO: Add <servlet> tags for each servlet here. -->
|
||||
<!-- TODO: Add <servlet-mapping> tags for each <servlet> here. -->
|
||||
<!-- TODO: Optionally add a <welcome-file-list> tag to display a welcome file. -->
|
||||
</web-app>
|
28
vtm-web-js/src/org/oscim/web/VtmWebJs.gwt.xml
Normal file
28
vtm-web-js/src/org/oscim/web/VtmWebJs.gwt.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<module rename-to="VtmWebApp">
|
||||
|
||||
<entry-point class="org.oscim.web.client.GwtLauncher" />
|
||||
|
||||
<inherits name="org.oscim.gdx.VtmWeb" />
|
||||
|
||||
<inherits name='org.timepedia.exporter.Exporter' />
|
||||
<set-property name="export" value="yes" />
|
||||
|
||||
<set-property name='gwt.logging.enabled' value='TRUE' />
|
||||
<set-property name='gwt.logging.consoleHandler' value='ENABLED' />
|
||||
<set-property name='gwt.logging.firebugHandler' value='DISABLED' />
|
||||
<set-property name='gwt.logging.popupHandler' value='DISABLED' />
|
||||
<set-property name="gwt.logging.logLevel" value="FINE" />
|
||||
|
||||
<!-- super dev mode -->
|
||||
<add-linker name="xsiframe" />
|
||||
<set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE' />
|
||||
<set-configuration-property name="devModeRedirectEnabled" value="true" />
|
||||
|
||||
<set-configuration-property name="gdx.assetpath" value="assets" />
|
||||
|
||||
<!-- for gradle build, commend out for eclipse build -->
|
||||
<set-configuration-property name="gdx.assetoutputpath" value="build/gwt/draftOut" />
|
||||
|
||||
<set-property name="user.agent" value="safari" />
|
||||
</module>
|
83
vtm-web-js/src/org/oscim/web/client/GwtLauncher.java
Normal file
83
vtm-web-js/src/org/oscim/web/client/GwtLauncher.java
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.web.client;
|
||||
|
||||
import org.oscim.core.Tile;
|
||||
import org.timepedia.exporter.client.ExporterUtil;
|
||||
|
||||
import com.badlogic.gdx.ApplicationListener;
|
||||
import com.badlogic.gdx.backends.gwt.GwtApplication;
|
||||
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
|
||||
import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderCallback;
|
||||
import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderState;
|
||||
|
||||
public class GwtLauncher extends GwtApplication {
|
||||
|
||||
@Override
|
||||
public void onModuleLoad() {
|
||||
//GWT.create(GwtGdxMap.class);
|
||||
//JsOverlays.init();
|
||||
ExporterUtil.exportAll();
|
||||
|
||||
super.onModuleLoad();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GwtApplicationConfiguration getConfig() {
|
||||
|
||||
GwtApplicationConfiguration cfg =
|
||||
new GwtApplicationConfiguration(getWindowWidth(),
|
||||
getWindowHeight());
|
||||
|
||||
cfg.canvasId = "map-canvas";
|
||||
cfg.stencil = true;
|
||||
cfg.fps = 120;
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationListener getApplicationListener() {
|
||||
Tile.SIZE = MapConfig.get().getTileSize();
|
||||
|
||||
return new GwtMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreloaderCallback getPreloaderCallback() {
|
||||
return new PreloaderCallback() {
|
||||
|
||||
@Override
|
||||
public void update(PreloaderState state) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String file) {
|
||||
//log.debug("error loading " + file);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static native int getWindowWidth() /*-{
|
||||
return $wnd.innerWidth;
|
||||
}-*/;
|
||||
|
||||
private static native int getWindowHeight() /*-{
|
||||
return $wnd.innerHeight;
|
||||
}-*/;
|
||||
|
||||
}
|
112
vtm-web-js/src/org/oscim/web/client/GwtMap.java
Normal file
112
vtm-web-js/src/org/oscim/web/client/GwtMap.java
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.web.client;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.GL20;
|
||||
import org.oscim.backend.GLAdapter;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.gdx.GdxAssets;
|
||||
import org.oscim.gdx.GdxMap;
|
||||
import org.oscim.gdx.client.GwtGdxGraphics;
|
||||
import org.oscim.gdx.client.UrlUpdater;
|
||||
import org.oscim.renderer.MapRenderer;
|
||||
import org.oscim.web.js.JsMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.gwt.GwtApplication;
|
||||
import com.google.gwt.user.client.Window;
|
||||
|
||||
public class GwtMap extends GdxMap {
|
||||
static final Logger log = LoggerFactory.getLogger(GwtMap.class);
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
|
||||
GwtGdxGraphics.init();
|
||||
GdxAssets.init("");
|
||||
CanvasAdapter.textScale = 0.7f;
|
||||
GLAdapter.init((GL20) Gdx.graphics.getGL20());
|
||||
GLAdapter.GDX_WEBGL_QUIRKS = true;
|
||||
MapRenderer.setBackgroundColor(0xffffff);
|
||||
|
||||
JsMap.init(mMap);
|
||||
|
||||
// stroke text takes about 70% cpu time in firefox:
|
||||
// https://bug568526.bugzilla.mozilla.org/attachment.cgi?id=447932
|
||||
// <- circle/stroke test 800ms firefox, 80ms chromium..
|
||||
// TODO use texture atlas to avoid drawing text-textures
|
||||
if (GwtApplication.agentInfo().isLinux() &&
|
||||
GwtApplication.agentInfo().isFirefox())
|
||||
GwtGdxGraphics.NO_STROKE_TEXT = true;
|
||||
|
||||
MapConfig c = MapConfig.get();
|
||||
super.create();
|
||||
|
||||
double lat = c.getLatitude();
|
||||
double lon = c.getLongitude();
|
||||
int zoom = c.getZoom();
|
||||
|
||||
float tilt = 0;
|
||||
float rotation = 0;
|
||||
|
||||
if (Window.Location.getHash() != null) {
|
||||
String hash = Window.Location.getHash();
|
||||
|
||||
hash = hash.substring(1);
|
||||
String[] pairs = hash.split(",");
|
||||
|
||||
for (String p : pairs) {
|
||||
try {
|
||||
if (p.startsWith("lat="))
|
||||
lat = Double.parseDouble(p.substring(4));
|
||||
else if (p.startsWith("lon="))
|
||||
lon = Double.parseDouble(p.substring(4));
|
||||
else if (p.startsWith("scale="))
|
||||
zoom = Integer.parseInt(p.substring(6));
|
||||
else if (p.startsWith("rot="))
|
||||
rotation = Float.parseFloat(p.substring(4));
|
||||
else if (p.startsWith("tilt="))
|
||||
tilt = Float.parseFloat(p.substring(5));
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
MapPosition p = new MapPosition();
|
||||
p.setZoomLevel(zoom);
|
||||
p.setPosition(lat, lon);
|
||||
p.bearing = rotation;
|
||||
p.tilt = tilt;
|
||||
mMap.setMapPosition(p);
|
||||
|
||||
UrlUpdater urlUpdater = new UrlUpdater(mMap);
|
||||
urlUpdater.scheduleRepeating(4000);
|
||||
}
|
||||
|
||||
private final native void createLayersN()/*-{
|
||||
$wnd.createLayers();
|
||||
}-*/;
|
||||
|
||||
@Override
|
||||
protected void createLayers() {
|
||||
log.debug("<<< create layers >>>");
|
||||
createLayersN();
|
||||
}
|
||||
}
|
57
vtm-web-js/src/org/oscim/web/client/MapConfig.java
Normal file
57
vtm-web-js/src/org/oscim/web/client/MapConfig.java
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.web.client;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
class MapConfig extends JavaScriptObject {
|
||||
protected MapConfig() {
|
||||
}
|
||||
|
||||
public static native MapConfig get()/*-{
|
||||
return $wnd.mapconfig;
|
||||
}-*/;
|
||||
|
||||
public final native double getLatitude() /*-{
|
||||
return this.latitude;
|
||||
}-*/;
|
||||
|
||||
public final native double getLongitude() /*-{
|
||||
return this.longitude;
|
||||
}-*/;
|
||||
|
||||
public final native int getZoom() /*-{
|
||||
return this.zoom;
|
||||
}-*/;
|
||||
|
||||
public final native String getTileSource() /*-{
|
||||
return this.tilesource;
|
||||
}-*/;
|
||||
|
||||
public final native String getTileUrl() /*-{
|
||||
return this.tileurl;
|
||||
}-*/;
|
||||
|
||||
public final native String getBackgroundLayer() /*-{
|
||||
return this.background;
|
||||
}-*/;
|
||||
|
||||
public final native int getTileSize() /*-{
|
||||
return this.tileSize || 256;
|
||||
}-*/;
|
||||
|
||||
}
|
22
vtm-web-js/src/org/oscim/web/js/JsBitmapTileLayer.java
Normal file
22
vtm-web-js/src/org/oscim/web/js/JsBitmapTileLayer.java
Normal file
@ -0,0 +1,22 @@
|
||||
package org.oscim.web.js;
|
||||
|
||||
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
|
||||
import org.oscim.map.Map;
|
||||
import org.oscim.tiling.TileSource;
|
||||
import org.timepedia.exporter.client.Export;
|
||||
import org.timepedia.exporter.client.ExportOverlay;
|
||||
import org.timepedia.exporter.client.ExportPackage;
|
||||
|
||||
@ExportPackage("vtm")
|
||||
@Export("BitmapTileLayer")
|
||||
public class JsBitmapTileLayer extends BitmapTileLayer implements ExportOverlay<BitmapTileLayer> {
|
||||
|
||||
public JsBitmapTileLayer(Map map, TileSource tileSource) {
|
||||
super(map, tileSource);
|
||||
}
|
||||
|
||||
// @ExportConstructor
|
||||
// public static BitmapTileLayer constructor(Map map, TileSource tileSource) {
|
||||
// return new JsBitmapTileLayer(map, tileSource);
|
||||
// }
|
||||
}
|
27
vtm-web-js/src/org/oscim/web/js/JsBitmapTileSource.java
Normal file
27
vtm-web-js/src/org/oscim/web/js/JsBitmapTileSource.java
Normal file
@ -0,0 +1,27 @@
|
||||
package org.oscim.web.js;
|
||||
|
||||
import org.oscim.tiling.ITileDataSource;
|
||||
import org.oscim.tiling.source.bitmap.BitmapTileSource;
|
||||
import org.timepedia.exporter.client.Export;
|
||||
import org.timepedia.exporter.client.ExportOverlay;
|
||||
import org.timepedia.exporter.client.ExportPackage;
|
||||
|
||||
@ExportPackage("vtm")
|
||||
@Export("BitmapTileSource")
|
||||
public class JsBitmapTileSource extends BitmapTileSource implements
|
||||
ExportOverlay<BitmapTileSource> {
|
||||
|
||||
public JsBitmapTileSource(String url, int zoomMin, int zoomMax) {
|
||||
super(url, zoomMin, zoomMax);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITileDataSource getDataSource() {
|
||||
return null;
|
||||
}
|
||||
// @ExportConstructor
|
||||
// public static BitmapTileSource constructor(String url, int zoomMin, int zoomMax) {
|
||||
// return new JsBitmapTileSource(url, zoomMin, zoomMax);
|
||||
// }
|
||||
|
||||
}
|
60
vtm-web-js/src/org/oscim/web/js/JsMap.java
Normal file
60
vtm-web-js/src/org/oscim/web/js/JsMap.java
Normal file
@ -0,0 +1,60 @@
|
||||
package org.oscim.web.js;
|
||||
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.layers.Layer;
|
||||
import org.oscim.map.Layers;
|
||||
import org.oscim.map.Map;
|
||||
import org.oscim.theme.IRenderTheme;
|
||||
import org.oscim.theme.ThemeLoader;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
import org.timepedia.exporter.client.Export;
|
||||
import org.timepedia.exporter.client.ExportPackage;
|
||||
import org.timepedia.exporter.client.Exportable;
|
||||
import org.timepedia.exporter.client.NoExport;
|
||||
|
||||
@ExportPackage("")
|
||||
@Export("map")
|
||||
public class JsMap implements Exportable {
|
||||
|
||||
static Map mMap;
|
||||
|
||||
@Export
|
||||
public static Map map() {
|
||||
return mMap;
|
||||
}
|
||||
|
||||
@Export
|
||||
public static Layers layers() {
|
||||
return mMap.layers();
|
||||
}
|
||||
|
||||
@Export
|
||||
public static boolean addLayer(Layer l) {
|
||||
return mMap.layers().add(l);
|
||||
}
|
||||
|
||||
@Export
|
||||
public static boolean getPosition(MapPosition pos) {
|
||||
return mMap.getMapPosition(pos);
|
||||
}
|
||||
|
||||
@Export
|
||||
public static void setPosition(MapPosition pos) {
|
||||
mMap.setMapPosition(pos);
|
||||
}
|
||||
|
||||
@Export
|
||||
public static IRenderTheme loadTheme(String theme) {
|
||||
return ThemeLoader.load(VtmThemes.valueOf(theme));
|
||||
}
|
||||
|
||||
@NoExport
|
||||
public static void init(Map map) {
|
||||
mMap = map;
|
||||
}
|
||||
|
||||
// @ExportInstanceMethod("foo")
|
||||
// public static String instanceMethod(Map instance, String surname) {
|
||||
// return instance.getName() + "-" + surname;
|
||||
// }
|
||||
}
|
144
vtm-web-js/src/org/oscim/web/js/JsOverlays.java
Normal file
144
vtm-web-js/src/org/oscim/web/js/JsOverlays.java
Normal file
@ -0,0 +1,144 @@
|
||||
package org.oscim.web.js;
|
||||
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.layers.GenericLayer;
|
||||
import org.oscim.layers.Layer;
|
||||
import org.oscim.layers.TileGridLayer;
|
||||
import org.oscim.layers.tile.vector.BuildingLayer;
|
||||
import org.oscim.layers.tile.vector.OsmTileLayer;
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
import org.oscim.map.Layers;
|
||||
import org.oscim.map.Map;
|
||||
import org.oscim.renderer.LayerRenderer;
|
||||
import org.oscim.theme.IRenderTheme;
|
||||
import org.oscim.tiling.TileSource;
|
||||
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
|
||||
import org.timepedia.exporter.client.Export;
|
||||
import org.timepedia.exporter.client.ExportOverlay;
|
||||
import org.timepedia.exporter.client.ExportPackage;
|
||||
|
||||
public final class JsOverlays {
|
||||
@ExportPackage("vtm")
|
||||
@Export("Layers")
|
||||
public interface XLayers extends ExportOverlay<Layers> {
|
||||
void add(Layer layer);
|
||||
}
|
||||
|
||||
@ExportPackage("vtm")
|
||||
@Export("Map")
|
||||
public interface XMap extends ExportOverlay<Map> {
|
||||
public abstract Layers layers();
|
||||
|
||||
public abstract void setMapPosition(MapPosition pos);
|
||||
|
||||
public abstract MapPosition getMapPosition();
|
||||
|
||||
}
|
||||
|
||||
@ExportPackage("vtm")
|
||||
@Export("MapPosition")
|
||||
public static class XMapPosition implements ExportOverlay<MapPosition> {
|
||||
public XMapPosition(double latitude, double longitude, double scale) {
|
||||
};
|
||||
|
||||
public XMapPosition() {
|
||||
};
|
||||
|
||||
public void setPosition(double latitude, double longitude) {
|
||||
}
|
||||
|
||||
public void setScale(double scale) {
|
||||
}
|
||||
}
|
||||
|
||||
@ExportPackage("vtm")
|
||||
@Export("GenericLayer")
|
||||
public abstract class XGenericLayer implements ExportOverlay<GenericLayer> {
|
||||
public XGenericLayer(Map map, LayerRenderer renderer) {
|
||||
}
|
||||
}
|
||||
|
||||
@ExportPackage("vtm")
|
||||
@Export("TileGridLayer")
|
||||
public static class XTileGridLayer implements ExportOverlay<TileGridLayer> {
|
||||
public XTileGridLayer(Map map) {
|
||||
}
|
||||
}
|
||||
|
||||
@ExportPackage("vtm")
|
||||
@Export("VectorTileLayer")
|
||||
public static class XVectorTileLayer implements ExportOverlay<VectorTileLayer> {
|
||||
public XVectorTileLayer(Map map, TileSource tileSource) {
|
||||
}
|
||||
|
||||
public boolean setTileSource(TileSource tileSource) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setRenderTheme(IRenderTheme theme) {
|
||||
}
|
||||
}
|
||||
|
||||
@ExportPackage("vtm")
|
||||
@Export("OsmTileLayer")
|
||||
public static class XOsmTileLayer implements ExportOverlay<OsmTileLayer> {
|
||||
public XOsmTileLayer(Map map) {
|
||||
}
|
||||
|
||||
public boolean setTileSource(TileSource tileSource) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setRenderTheme(IRenderTheme theme) {
|
||||
}
|
||||
}
|
||||
|
||||
// @ExportPackage("vtm")
|
||||
// @Export("OsmLanduseJsonTileSource")
|
||||
// public static class XOsmLanduseJsonTileSource implements
|
||||
// ExportOverlay<OsmLanduseJsonTileSource> {
|
||||
// public XOsmLanduseJsonTileSource() {
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @ExportPackage("vtm")
|
||||
// @Export("HighroadJsonTileSource")
|
||||
// public static class XHighroadJsonTileSource implements
|
||||
// ExportOverlay<HighroadJsonTileSource> {
|
||||
// public XHighroadJsonTileSource() {
|
||||
// }
|
||||
// }
|
||||
|
||||
@ExportPackage("vtm")
|
||||
@Export("OSciMap4TileSource")
|
||||
public static class XOSciMap4TileSource implements
|
||||
ExportOverlay<OSciMap4TileSource> {
|
||||
public XOSciMap4TileSource(String url) {
|
||||
}
|
||||
|
||||
public XOSciMap4TileSource() {
|
||||
}
|
||||
}
|
||||
|
||||
@ExportPackage("vtm")
|
||||
@Export("LabelLayer")
|
||||
public static class XLabelLayer implements
|
||||
ExportOverlay<LabelLayer> {
|
||||
public XLabelLayer(Map map, VectorTileLayer l) {
|
||||
}
|
||||
}
|
||||
|
||||
@ExportPackage("vtm")
|
||||
@Export("BuildingLayer")
|
||||
public static class XBuildingLayer implements
|
||||
ExportOverlay<BuildingLayer> {
|
||||
public XBuildingLayer(Map map, VectorTileLayer l) {
|
||||
}
|
||||
}
|
||||
|
||||
// @ExportPackage("vtm")
|
||||
// @Export("Viewport")
|
||||
// public interface XViewport extends ExportOverlay
|
||||
//
|
||||
}
|
102
vtm-web-js/war/default.css
Normal file
102
vtm-web-js/war/default.css
Normal file
@ -0,0 +1,102 @@
|
||||
.header {
|
||||
background-color: #ddd;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
html,body {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0 0 0 0;
|
||||
font-family: Arial, "MS Trebuchet", sans-serif;
|
||||
}
|
||||
|
||||
#credits {
|
||||
position: absolute;
|
||||
bottom: 0.2em;
|
||||
right: 0.2em;
|
||||
z-index: 20000;
|
||||
color: white;
|
||||
background-color: #000;
|
||||
opacity: 0.5;
|
||||
padding: 0.2em 0.5em 0.2em 0.5em;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#credits a {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
font-variant: small-caps;
|
||||
}
|
||||
|
||||
#search {
|
||||
z-index: 20000;
|
||||
position: absolute;
|
||||
top: 0.5em;
|
||||
left: 0.5em;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
#listContainer {
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
#nameFieldContainer,.gwt-TextBox {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
/* Turn on a 16x16 scrollbar */
|
||||
::-webkit-scrollbar {
|
||||
width: 10px;
|
||||
height: 0px;
|
||||
}
|
||||
|
||||
/* Turn on single button up on top, and down on bottom */
|
||||
::-webkit-scrollbar-button:start:decrement,::-webkit-scrollbar-button:end:increment
|
||||
{
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Turn off the down area up on top, and up area on bottom */
|
||||
::-webkit-scrollbar-button:vertical:start:increment,::-webkit-scrollbar-button:vertical:end:decrement
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Place The scroll down button at the bottom */
|
||||
::-webkit-scrollbar-button:end:increment {
|
||||
/*background-image: url(images/scroll_cntrl_dwn.png);*/
|
||||
}
|
||||
|
||||
/* Place The scroll up button at the up */
|
||||
::-webkit-scrollbar-button:start:decrement {
|
||||
/*background-image: url(images/scroll_cntrl_up.png);*/
|
||||
}
|
||||
|
||||
/* Top area above thumb and below up button */
|
||||
::-webkit-scrollbar-track-piece:vertical:start {
|
||||
/*background-image: url(images/scroll_gutter_top.png), url(images/scroll_gutter_mid.png);
|
||||
background-repeat: no-repeat, repeat-y;*/
|
||||
}
|
||||
|
||||
/* Bottom area below thumb and down button */
|
||||
::-webkit-scrollbar-track-piece:vertical:end {
|
||||
/*background-image: url(images/scroll_gutter_btm.png), url(images/scroll_gutter_mid.png);
|
||||
background-repeat: no-repeat, repeat-y;
|
||||
background-position: bottom left, 0 0;*/
|
||||
}
|
||||
|
||||
/* The thumb itself */
|
||||
::-webkit-scrollbar-thumb:vertical {
|
||||
height: 56px;
|
||||
width: 12px;
|
||||
/* -webkit-border-image: url(images/scroll_thumb.png) 8 0 8 0 stretch stretch;*/
|
||||
background-color: #DDDDDD;
|
||||
opacity: 0.5;
|
||||
}
|
33
vtm-web-js/war/index.html
Normal file
33
vtm-web-js/war/index.html
Normal file
@ -0,0 +1,33 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>vtm-web-js</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="default.css">
|
||||
</head>
|
||||
|
||||
<body oncontextmenu="return false;">
|
||||
<div id="canvas-area"
|
||||
style="position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;">
|
||||
<canvas id="map-canvas">
|
||||
Your browser does not support the HTML5 canvas tag.
|
||||
</canvas>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="map.js"></script>
|
||||
|
||||
<script type="text/javascript" src="VtmWebApp/js/_tessellate.js"></script>
|
||||
<script type="text/javascript" src="VtmWebApp/js/tessellate.js"></script>
|
||||
<script type="text/javascript" src="VtmWebApp/VtmWebApp.nocache.js"></script>
|
||||
|
||||
<div id="credits">
|
||||
<a href="https://github.com/hjanetzek/vtm">Source</a> | map data © <a
|
||||
href="http://www.openstreemap.org">OpenStreetMap</a> contributors | <a
|
||||
href="http://www.opensciencemap.org">OpenScienceMap</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
42
vtm-web-js/war/map.js
Normal file
42
vtm-web-js/war/map.js
Normal file
@ -0,0 +1,42 @@
|
||||
var mapconfig = {
|
||||
zoom : 12,
|
||||
latitude : 53.075,
|
||||
longitude : 8.8080,
|
||||
tileSize : 400
|
||||
}
|
||||
|
||||
function createLayers() {
|
||||
var m = map.map();
|
||||
|
||||
// var t = map.loadTheme("DEFAULT");
|
||||
// var ts = new vtm.OSciMap4TileSource();
|
||||
// var l = new vtm.OsmTileLayer(m);
|
||||
// l.setTileSource(ts)
|
||||
// l.setRenderTheme(t)
|
||||
|
||||
var s = new vtm.BitmapTileSource("http://a.tile.stamen.com/toner", 0, 18);
|
||||
var l = new vtm.BitmapTileLayer(m, s);
|
||||
map.addLayer(l)
|
||||
// map.addLayer(new vtm.BuildingLayer(m, l))
|
||||
// map.addLayer(new vtm.LabelLayer(m, l))
|
||||
|
||||
// t = map.loadTheme("TRONRENDER")
|
||||
// ts = new vtm.OsmLanduseJsonTileSource()
|
||||
// l = new vtm.VectorTileLayer(m, ts)
|
||||
// l.setRenderTheme(t)
|
||||
// map.addLayer(l)
|
||||
}
|
||||
|
||||
function canvasResize() {
|
||||
div = document.getElementById('canvas-area')
|
||||
canvas = document.getElementById('map-canvas')
|
||||
var w = div.scrollWidth;
|
||||
var h = div.scrollHeight;
|
||||
// console.log(div.clientHeight + " " + div.clientWidth)
|
||||
canvas.width = w;
|
||||
canvas.height = h;
|
||||
canvas.style.width = w + 'px';
|
||||
canvas.style.height = h + 'px';
|
||||
}
|
||||
canvasResize();
|
||||
window.addEventListener('resize', canvasResize, false);
|
51
vtm-web/src/org/oscim/gdx/client/UrlUpdater.java
Normal file
51
vtm-web/src/org/oscim/gdx/client/UrlUpdater.java
Normal file
@ -0,0 +1,51 @@
|
||||
package org.oscim.gdx.client;
|
||||
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.core.MercatorProjection;
|
||||
import org.oscim.map.Map;
|
||||
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.Window;
|
||||
|
||||
public class UrlUpdater extends Timer {
|
||||
private int curLon, curLat, curZoom, curTilt, curRot;
|
||||
private MapPosition pos = new MapPosition();
|
||||
private final Map mMap;
|
||||
private String mParams = "";
|
||||
|
||||
public UrlUpdater(Map map) {
|
||||
mMap = map;
|
||||
}
|
||||
|
||||
public void setParams(String params) {
|
||||
mParams = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
mMap.viewport().getMapPosition(pos);
|
||||
int lat = (int) (MercatorProjection.toLatitude(pos.y) * 1000);
|
||||
int lon = (int) (MercatorProjection.toLongitude(pos.x) * 1000);
|
||||
int rot = (int) (pos.bearing);
|
||||
rot = (int) (pos.bearing) % 360;
|
||||
//rot = rot < 0 ? -rot : rot;
|
||||
|
||||
if (curZoom != pos.zoomLevel || curLat != lat || curLon != lon
|
||||
|| curTilt != rot || curRot != (int) (pos.bearing)) {
|
||||
|
||||
curLat = lat;
|
||||
curLon = lon;
|
||||
curZoom = pos.zoomLevel;
|
||||
curTilt = (int) pos.tilt;
|
||||
curRot = rot;
|
||||
|
||||
String newURL = Window.Location
|
||||
.createUrlBuilder()
|
||||
.setHash(mParams + "scale=" + pos.zoomLevel + ",rot=" + curRot
|
||||
+ ",tilt=" + curTilt + ",lat=" + (curLat / 1000f)
|
||||
+ ",lon=" + (curLon / 1000f))
|
||||
.buildString();
|
||||
Window.Location.replace(newURL);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user