Skip to content

fix #1176 implemented GraticuleLayer for leaflet #1180

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

Merged
merged 2 commits into from
Oct 20, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2016

* 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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

showOriginLabel

Copy link
Contributor Author

@saidaipparla saidaipparla Oct 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should i keep this showOriginLabel:(0,0) as initiial parameter ? instead of true

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the name is wrong, no showshowOriginLabel but showOriginLabel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

redraw: 'move'
}, options);
if (SimpleGraticule) {
return new SimpleGraticule(graticuleOptions);
}
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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