-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Add Leaflet layers #215
Merged
Merged
Add Leaflet layers #215
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cb25972
add leaflet layers
PeterTheOne 853b579
Merge branch 'master' into leaflet-layers
PeterTheOne 70c20c0
fix loading of dependencies
PeterTheOne 2c4c2cf
add missing i18n
PeterTheOne a1c5564
disable mapbox support because of missing api key integration
PeterTheOne df0997c
fix LayerApiKeys settings
PeterTheOne 51607cc
load leaflet layer dependencies in renderMap function
PeterTheOne 58efc26
move addLayerDependencies to MappingService
PeterTheOne 6b88572
cleanup loading of layer dependencies
PeterTheOne f372909
change layers settings to array of booleans
PeterTheOne 7470a25
rename addLayerDependencies to addHtmlDependencies
PeterTheOne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,6 +145,13 @@ protected function handleMarkerData( array &$params, Parser $parser ) { | |
|
||
if ( $params['mappingservice'] === 'openlayers' ) { | ||
$params['layers'] = self::evilOpenLayersHack( $params['layers'] ); | ||
} else if ( $params['mappingservice'] === 'leaflet' ) { | ||
global $egMapsLeafletLayerDependencies; | ||
$layerDependencies = []; | ||
$layerDependencies[] = "<script src='https://open.mapquestapi.com/sdk/leaflet/v2.2/mq-map.js?key=" . $GLOBALS['egMapsLeafletLayersApiKeys']['MapQuestOpen'] . "'></script>"; | ||
MapsMappingServices::getServiceInstance( 'leaflet' )->addLayerDependencies( | ||
array_unique( $layerDependencies ) | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you putting this code here? It seems to have little to do with the method and not need anything from it |
||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
* @author Peter Grassberger < [email protected] > | ||
*/ | ||
|
||
(function ($, mw, L) { | ||
(function ($, mw, L, MQ) { | ||
$.fn.leafletmaps = function ( options ) { | ||
var _this = this; | ||
this.map = null; | ||
|
@@ -252,9 +252,20 @@ | |
this.map = map; | ||
|
||
// add an OpenStreetMap tile layer | ||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { | ||
var layerOptions = { | ||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' | ||
}).addTo(map); | ||
}; | ||
if (options.layer === 'OpenStreetMap') { | ||
new L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', layerOptions).addTo(map); | ||
} else if (options.layer === 'MapQuestOpen') { | ||
new MQ.TileLayer(layerOptions).addTo(map); | ||
} else { | ||
new L.tileLayer.provider(options.layer, layerOptions).addTo(map); | ||
} | ||
|
||
$.each(options.overlaylayers, function(index, overlaylayer) { | ||
L.tileLayer.provider(overlaylayer).addTo(_this.map); | ||
}); | ||
|
||
if (options.resizable) { | ||
//TODO: Fix moving map when resized | ||
|
@@ -334,6 +345,9 @@ | |
|
||
this.getDependencies = function ( options ) { | ||
var dependencies = []; | ||
if (options.layer !== 'OpenStreetMap' || options.overlaylayers.length > 0) { | ||
dependencies.push( 'ext.maps.leaflet.providers' ); | ||
} | ||
if (options.enablefullscreen) { | ||
dependencies.push( 'ext.maps.leaflet.fullscreen' ); | ||
} | ||
|
@@ -353,4 +367,4 @@ | |
return this; | ||
|
||
}; | ||
})(jQuery, window.mediaWiki, L); | ||
})(jQuery, window.mediaWiki, L, MQ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"rules": { | ||
"camelcase": 2, | ||
"quotes": [2, "single", "avoid-escape"], | ||
"no-mixed-spaces-and-tabs": [2, "smart-tabs"], | ||
"space-before-function-paren": 2, | ||
"space-in-parens": 2, | ||
"object-curly-spacing": 2, | ||
"array-bracket-spacing": 2, | ||
"computed-property-spacing": 2, | ||
"space-before-blocks": 2, | ||
"keyword-spacing": 2, | ||
"no-lonely-if": 2, | ||
"comma-style": 2, | ||
"no-underscore-dangle": 0, | ||
"no-constant-condition": 0, | ||
"no-multi-spaces": 0, | ||
"strict": 0, | ||
"key-spacing": 0, | ||
"no-shadow": 0, | ||
"no-unused-vars": 2, | ||
"eqeqeq": 2 | ||
}, | ||
"globals": { | ||
"L": true, | ||
"module": false, | ||
"define": false, | ||
"require": true | ||
}, | ||
"plugins": [ | ||
"html" | ||
], | ||
"settings": { | ||
"html/report-bad-indent": 2 | ||
}, | ||
"env": { | ||
"browser": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
leaflet-providers.min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"commitMessage": "Bumped version to %s", | ||
"tagName": "%s", | ||
"scripts": { | ||
"preupdate": "npm run min", | ||
"postupdate": "git push && git push --tags && npm publish" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
language: node_js | ||
node_js: | ||
- "0.10" | ||
notifications: | ||
email: false | ||
git: | ||
depth: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
# Leaflet-providers changelog | ||
|
||
## 1.1.14 (2016-07-15) | ||
- Remove MapQuest, fixes #219 | ||
- Accidently skipped v1.1.12 and v1.1.13 | ||
|
||
## 1.1.11 (2016-06-04) | ||
- Added protocol relativity to OSM FR, OSM HOT and Hydda providers (#214, #215). | ||
|
||
## 1.1.9 (2016-03-23) | ||
- Re-added HERE layers #209, discussion in #206. | ||
|
||
## 1.1.8 (2016-03-22) | ||
- Removed HERE layers #206 | ||
|
||
## 1.1.7 (2015-12-16) | ||
- Removed Acetate tile layers #198 | ||
|
||
## 1.1.6 (2015-11-03) | ||
- Removed most of the NLS layers per NLS request #193, fixes #178 | ||
- Added new variants to the HERE provider #183 by [@andreaswc](https://github.com/andreaswc) | ||
- Added some tests to make sure all the placeholders in the url template are replaced #188 | ||
|
||
## 1.1.5 (2015-10-01) | ||
- Improvements for the NLS layers #182 by [@tomhughes](https://github.com/tomhughes) | ||
- Check for valid bounds before fitting the preview map to undefined (fixes #185) | ||
- Add bounds for FreeMapSK (fixes #184) | ||
- Fix Stamen layers with `.jpg` extension (#187, fixes #184) | ||
|
||
## 1.1.4 (2015-09-27) | ||
- Only include the interesting files in the npm package #180 | ||
- Add GSGS_Ireland to NLS provider with `tms:true` to invert y-axis #181 | ||
|
||
## 1.1.3 (2015-09-26) | ||
- Add various historical layers of the Natioanal library of Scotland (NLS) #179 | ||
- Add a page to visually check bounds #179 | ||
|
||
## 1.1.2 (2015-09-05) | ||
- Add CartoDB labels-only styles #170 by [@almccon](https://github.com/almccon) | ||
- Implement commonjs module #172 | ||
- Added retina URL option #177, [@routexl](https://github.com/routexl) | ||
|
||
## 1.1.1 (2015-06-22) | ||
- Update Mapbox API to v4 #167 by [@gutenye](https://github.com/gutenye) | ||
- Started maintaining a changelog in CHANGELOG.md. |
10 changes: 10 additions & 0 deletions
10
includes/services/Leaflet/leaflet-providers/CONTRIBUTING.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
So you want to add a layer? | ||
======= | ||
|
||
Yay! go add it to the leaflet-providers.js as long as it follows the following | ||
rules: | ||
|
||
- Don't violate a providers TOS (if it exists, include a link to it) | ||
- Don't pre-populate api keys with working keys. | ||
- It should be a basic tile source, no exteral libraries etc. | ||
- The owner hasn't asked us to remove it (hasn't happened yet) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has occurred to me lately that while this is a sensible data structure for inside of the code, that for configuration it causes some issue: unless you're adding something, you'll need to redefine the array, or use some kind of filtering PHP code. So if the user wants to simply disable a single layer, the easiest thing for them to do is to copy the thing and remove the entry, which is kinda silly, and then also does not keep them up to date with the latest entries in new versions.
How about doing
Then they can easily disable one. You'd probably want to map it to a normal list when reading the config then, though that is really simple...
Thoughts @kghbln?