/echo simulates AJAX calls: JSON: /echo/json/ JSONP: //jsfiddle.net/echo/jsonp/ HTML: /echo/html/ XML: /echo/xml/ JSFiddle or its authors are not responsible or liable for any loss or damage of any kind during the usage of provided code. online javascript editor, testing javascript online, online ide, online code editor, html, css, coffeescript, scss online editor <,iframe width='100%' height='300' src='{embedSrc}' allowfullscreen='allowfullscreen' frameborder='0'>,<,/iframe>, JSFiddle or its authors are not responsible or liable for any loss or damage of any kind during the usage of provided code. var map, var denominator = 1000 / Math.cos(50 * (Math.PI / 180)), function Initialize() { LoadMap(40.36, -3.66, 6), } //*************************************** // MAP //*************************************** function LoadMap(lat, lon, zoom) { //Define map options var fromProjection = new OpenLayers.Projection('EPSG:4326'), // transform from 3857? //4326,900913 var toProjection = new OpenLayers.Projection('EPSG:900913'), // to Spherical Mercator Projection var extent = new OpenLayers.Bounds(-7.5, 36.5, -2.5, 39.5).transform(fromProjection, toProjection), // (W,S,E,N) var options = { projection: 'EPSG:900913', units: 'km' }, map = new OpenLayers.Map('map', options), //base map var ghyb = new OpenLayers.Layer.Google('Google Hybrid', { type: google.maps.MapTypeId.HYBRID, visibility: false }), //numZoomLevels: 22 //Switch control map.addLayers([ghyb]), map.addControls([new OpenLayers.Control.Navigation(), new OpenLayers.Control.PanZoomBar()]), //Build up all controls var lonLat = new OpenLayers.LonLat(lon, lat).transform( fromProjection, // transform from WGS 1984 toProjection // to Spherical Mercator Projection ), //Center the map map.setCenter(lonLat), map.zoomTo(zoom), //add Rectangle var style = new OpenLayers.Style({ fillOpacity: 0.0, fillColor: '#7ab800', strokeOpacity: 1, strokeColor: '#7ab800', strokeWidth: 3 }), boundingLayer = new OpenLayers.Layer.Vector('Bounding Layer', { styleMap: new OpenLayers.StyleMap(style) }), box = new OpenLayers.Feature.Vector(extent.toGeometry()), boundingLayer.addFeatures(box), map.addLayer(boundingLayer), //Circles layer for (i = 36.5, i <,= 39.5, i = i + 0.25) { for (j = -7.5, j <,= -2.5, j = j + 0.25) { lonLatLocation = new OpenLayers.LonLat(j, i).transform( // LonLat(lon, lat) fromProjection, // transform from WGS 1984 toProjection // to Spherical Mercator Projection ), vectorLayer = new OpenLayers.Layer.Vector('Circles Layer'), map.addLayer(vectorLayer), createCircle(new OpenLayers.Geometry.Point(lonLatLocation.lon, lonLatLocation.lat)), } } } //Add circles to circles layer function createCircle(center) { vectorLayer.removeAllFeatures(), var sunpoly = OpenLayers.Geometry.Polygon.createRegularPolygon( center, denominator, 36, 0), var suncircle = new OpenLayers.Feature.Vector(sunpoly, null, { fillOpacity: 1.0, fillColor: '#FF0000', strokeOpacity: 1, strokeColor: '#FF0000', strokeWidth: 3 }), vectorLayer.addFeatures([suncircle]), } var bench = document.getElementById('ms'), var then = performance.now(), Initialize(), var time = performance.now()-then, bench.innerHTML = 'Loaded in ' + time + ' ms', Source.


Яндекс.Метрика Рейтинг@Mail.ru Free Web Counter
page counter
Last Modified: April 22, 2016 @ 1:03 pm