From aeceb09996a22ee19bb60ab8f26e14b196f23e32 Mon Sep 17 00:00:00 2001 From: woutergd Date: Sun, 28 Jun 2015 12:34:45 +0200 Subject: [PATCH] Added basic tests for openlayers 3 definition --- openlayers/openlayers-tests.ts | 93 ++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 openlayers/openlayers-tests.ts diff --git a/openlayers/openlayers-tests.ts b/openlayers/openlayers-tests.ts new file mode 100644 index 000000000..2da9e19a3 --- /dev/null +++ b/openlayers/openlayers-tests.ts @@ -0,0 +1,93 @@ +/// + +// Attribution +var attribution: ol.Attribution = new ol.Attribution({ + html: "", +}); + +// View +var view: ol.View = new ol.View({ + center: [0, 0], + zoom: 1, +}); + +// Tile layer +var tileLayer: ol.layer.Tile = new ol.layer.Tile({ + source: new ol.source.MapQuest({ layer: 'osm' }) +}); + +// Map +var map: ol.Map = new ol.Map({ + view: view, + layers: [ tileLayer ], + target: 'map' +}); + +// Animation +var bounce = ol.animation.bounce({ + resolution: map.getView().getResolution(), + duration: 1000, + start: 0, +}); +var pam = ol.animation.pan({ + duration: 1000, + start: 0, + source: [0, 0] +}); +var rotate = ol.animation.rotate({ + duration: 1000, + start: 0, + anchor: [0, 0], + resolution: map.getView().getResolution() +}); +var zoom = ol.animation.zoom({ + duration: 1000, + start: 0, + resolution: map.getView().getResolution() +}); +map.beforeRender(zoom); +map.getView().setResolution(map.getView().getResolution() * 2); + +// Geolocation +var geolocation: ol.Geolocation = new ol.Geolocation({ + // take the projection to use from the map's view + projection: view.getProjection() +}); +geolocation.on('change', function (evt) { + window.console.log(geolocation.getPosition()); +}); + +// Graticule +var graticule: ol.Graticule = new ol.Graticule(); +var graticule: ol.Graticule = new ol.Graticule({ + map: map, +}); +var graticuleMap: ol.Map = graticule.getMap(); +var graticuleMeridians: Array = graticule.getMeridians(); +var graticuleParallels: Array = graticule.getParallels(); +graticule.setMap(graticuleMap); + +// Device orientation +var deviceOrientation: ol.DeviceOrientation = new ol.DeviceOrientation({ + tracking: true, +}); +deviceOrientation.on('change', function (evt) { + window.console.log(deviceOrientation.getHeading()); +}); + +// Overlay +var popup: ol.Overlay = new ol.Overlay({ + element: document.getElementById('popup') +}); +popup.setPosition([10, 10]); +map.addOverlay(popup); +var popupElement: Element = popup.getElement(); +var popupMap: ol.Map = popup.getMap(); +var popupOffset: Array = popup.getOffset(); +var popupCoordinate: ol.Coordinate = popup.getPosition(); +var popupPositioning: ol.OverlayPositioning = popup.getPositioning(); +popup.setElement(popupElement); +popup.setMap(popupMap); +popup.setOffset(popupOffset); +popup.setPosition(popupCoordinate); +popup.setPositioning(popupPositioning); \ No newline at end of file