Skip to content

Commit

Permalink
fix geosolutions-it#1176 implemented GraticuleLayer for leaflet
Browse files Browse the repository at this point in the history
  • Loading branch information
saidaipparla committed Oct 19, 2016
1 parent d757ced commit 79fc884
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
14 changes: 14 additions & 0 deletions web/client/components/map/leaflet/__tests__/Layer-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var expect = require('expect');

require('../../../../utils/leaflet/Layers');
require('../plugins/OSMLayer');
require('../plugins/GraticuleLayer');
require('../plugins/WMSLayer');
require('../plugins/GoogleLayer');
require('../plugins/BingLayer');
Expand Down Expand Up @@ -101,6 +102,19 @@ describe('Leaflet layer', () => {
expect(lcount).toBe(1);
});

it('creates a graticule layer for leaflet map', () => {
var options = {};
// create layers
var layer = ReactDOM.render(
<LeafLetLayer type="graticule"
options={options} map={map}/>, document.getElementById("container"));
var lcount = 0;
expect(layer).toExist();
// count layers
map.eachLayer(function() {lcount++; });
expect(lcount).toBe(1);
});

it('creates a mapquest layer for leaflet map without API key', () => {
var options = {
"source": "mapquest",
Expand Down
30 changes: 30 additions & 0 deletions web/client/components/map/leaflet/plugins/GraticuleLayer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright 2015, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

const Layers = require('../../../../utils/leaflet/Layers');
const SimpleGraticule = require('leaflet-simple-graticule/L.SimpleGraticule');
const assign = require('object-assign');

require('leaflet-simple-graticule/L.SimpleGraticule.css');

Layers.registerType('graticule', {
create: (options) => {
const graticuleOptions = assign({
interval: 20,
showshowOriginLabel: true,
redraw: 'move'
}, options);
if (SimpleGraticule) {
return new SimpleGraticule(graticuleOptions);
}
return false;
},
isValid: () => {
return SimpleGraticule ? true : false;
}
});
1 change: 1 addition & 0 deletions web/client/components/map/leaflet/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
module.exports = {
BingLayer: require('./BingLayer'),
Commons: require('./Commons'),
GraticuleLayer: require('./GraticuleLayer'),
GoogleLayer: require('./GoogleLayer'),
MapQuest: require('./MapQuest'),
OSMLayer: require('./OSMLayer'),
Expand Down
4 changes: 4 additions & 0 deletions web/client/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
20037508.34, 20037508.34
],
"layers": [
{
"type": "graticule",
"visibility": true
},
{
"type": "osm",
"title": "Open Street Map",
Expand Down

0 comments on commit 79fc884

Please sign in to comment.