Introducing OpenLayers 3 http://ol3js.org/
(Image courtesy of the OSM-3D.org project)
var view = new ol.View2D({ center: [0, 0], zoom: 0 }); var map = new ol.Map({ target: 'map', layers: [layer], view: view });hello world example
var osm = new ol.layer.TileLayer({ source: new ol.source.OSM() });
var bing = new ol.layer.TileLayer({ source: new ol.source.BingMaps({ // your key here key: 'AlQLZ0-5yk301_ESrmN...', style: 'AerialWithLabels' }) }));
var mapbox = new ol.layer.TileLayer({ source: new ol.source.TileJSON({ url: '//api.tiles.mapbox.com/v3/mapbox.world-dark.jsonp' }) });tiles galore example
var vector = new ol.layer.Vector({ source: new ol.source.Vector({ projection: ol.projection.get('EPSG:4326') }) });more to come on vector ...
var marker = new ol.Overlay({ map: map, position: buriedTreasure, element: document.createTextElement('X marks the spot') });
var el = document.getElementById('popup'); var popup = new ol.Overlay({ map: map, element: el }); map.on('click', function(evt) { $(el).popover({ 'placement': 'top', 'html': true, 'content': 'Roll your own popup!' }); $(el).popover('show'); popup.setPosition(evt.getCoordinate()); });overlay example
function fly(map, home, duration) { var view = map.getView().getView2D(); var start = +new Date(); var pan = ol.animation.pan({ duration: duration, source: view.getCenter(), start: start }); var bounce = ol.animation.bounce({ duration: duration, resolution: 4 * view.getResolution(), start: start }); map.addPreRenderFunctions([pan, bounce]); view.setCenter(home); }animation example
map.getFeatures({ pixel: evt.getPixel(), layers: [countries], // optional success: function(result) { $('#info').html(''); for (var i = 0, ii = result[0].length; i < ii; ++i) { $('#info').append(result[0][i].get('name') + '<br>'); } } });synthetic data example
ol.parser.GeoJSON.prototype.parsePolygon_ = function(json, opt_vertices) { return new ol.geom.Polygon( json.coordinates, opt_vertices); };
vector.parseFeatures(xhr.responseText, geojson, proj);
goog.provide('ANamespace.ASubNamespace.AClass'); ANamespace.ASubNamespace.AClass = function() { this.aProperty = 'prop1'; }; ANamespace.ASubNamespace.AClass.prototype.aMethod = function() { this.aProperty = 'change'; }; var anInstance = new ANamespace.ASubNamespace.AClass(); anInstance.aMethod();compiles to:
window.b=new function(){this.a="prop1"};window.b.a="change";