Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #1176 implemented GraticuleLayer for leaflet #1180

Merged
merged 2 commits into from
Oct 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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