Skip to content

Commit

Permalink
fix #1176 implemented GraticuleLayer for leaflet (#1180)
Browse files Browse the repository at this point in the history
* fix #1176 implemented GraticuleLayer for leaflet

* fix typo, year and returned null
  • Loading branch information
saidaipparla authored and mbarto committed Oct 20, 2016
1 parent e3ce9ba commit f1bea6b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"leaflet-draw": "0.2.4",
"leaflet-minimap": "3.3.1",
"leaflet-plugins": "https://github.com/Polyconseil/leaflet-plugins/tarball/master",
"leaflet-simple-graticule": "1.0.2",
"leaflet.locatecontrol": "0.45.1",
"lodash": "3.10.1",
"moment": "2.13.0",
Expand Down
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 2016, 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,
showOriginLabel: true,
redraw: 'move'
}, options);
if (SimpleGraticule) {
return new SimpleGraticule(graticuleOptions);
}
return null;
},
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 f1bea6b

Please sign in to comment.