Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First integration of Leaflet.RevealOSM
- Loading branch information
1 parent
3e95195
commit 35e2669
Showing
8 changed files
with
181 additions
and
13 deletions.
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
carte_fluviale/static/carte_fluviale/CustomRevealOSM.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,110 @@ | ||
var RevealOSM = L.Control.RevealOSM.extend({ | ||
|
||
initialize: function (options) { | ||
L.Control.RevealOSM.prototype.initialize.call(this, options); | ||
this.options.excludeKeys = [ | ||
/source/, | ||
/^ref/, | ||
/seamark/, | ||
/^name$/, | ||
/^harbour$/, | ||
/^leisure$/, | ||
/^lock$/, | ||
/^boat$/, | ||
/^motorboat$/, | ||
/^waterway$/, | ||
/^lock_name$/, | ||
/^man_made$/, | ||
/^harbour\:category$/ | ||
]; | ||
this.options.helpText = "Click on harbours, locks or piers"; | ||
this.options.translateKeys = { | ||
'harbour:channel': 'VHF', | ||
'harbour:draft': 'max draft', | ||
'harbour:length': 'max length' | ||
}; | ||
}, | ||
|
||
getQueryTemplate: function () { | ||
var template; | ||
if (this._map.getZoom() < 13) { | ||
template = '[out:json];node(around:{radius},{lat},{lng})[harbour];out body qt 1;'; | ||
} | ||
else { | ||
template = '[out:json];(node(around:{radius},{lat},{lng})[harbour];way(around:{radius},{lat},{lng})[lock];way(around:{radius},{lat},{lng})[man_made=pier]);out body qt 1;'; | ||
} | ||
return template; | ||
}, | ||
|
||
getRadius: function () { | ||
return this.options.radius || 300 - (15 * this._map.getZoom()); | ||
}, | ||
|
||
formatTitle: function (element) { | ||
var title, | ||
className, | ||
keys = ['lock:name', 'lock_name', 'name']; | ||
for (var i=0, l=keys.length; i<l; i++) { | ||
if (element.tags[keys[i]]) { | ||
title = element.tags[keys[i]]; | ||
break; | ||
} | ||
} | ||
if (!title && element.tags['man_made']) { | ||
title = element.tags['man_made']; | ||
className = "pier"; | ||
} | ||
if (element.tags['harbour'] == 'yes') { | ||
className = "harbour"; | ||
if (element.tags['seasonal'] == 'yes') { | ||
className = "seasonal"; | ||
} | ||
} | ||
if (title) { | ||
if (className) { className = ' class="' + className + '"';} | ||
title = "<h4" + className + ">" + title + "</h4>"; | ||
} | ||
return title; | ||
}, | ||
|
||
cleanKey: function (element, key) { | ||
key = L.Control.RevealOSM.prototype.cleanKey.call(this, element, key); | ||
return key.replace('harbour', ''); | ||
}, | ||
|
||
formatIcon: function (element, key) { | ||
var icon = ""; | ||
if (key.match(/vhf|channel/i)) { | ||
icon = '<div class="icon vhf info">' + element.tags[key] + "</div>"; | ||
} | ||
return icon; | ||
}, | ||
|
||
formatPhone: function (element, key) { | ||
var output = ""; | ||
if (key.match(/phone/i)) { | ||
output = '<div class="phone">' + element.tags[key] + "</div>"; | ||
} | ||
return output; | ||
} | ||
|
||
// formatContent: function (element) { | ||
// var content = "", | ||
// raw_tags = "", | ||
// phone = "", | ||
// title = this.formatTitle(element); | ||
// if (title) { | ||
// content += title; | ||
// } | ||
// for (var tag in element.tags) { | ||
// content += this.formatIcon(element, tag); | ||
// phone += this.formatPhone(element, tag); | ||
// if (!this.isAllowedKey(tag)) { continue;} | ||
// raw_tags += this.formatKey(element, tag); | ||
// } | ||
// content += phone; | ||
// content += '<div class="raw_tags">' + raw_tags + '</div>'; | ||
// return content; | ||
// } | ||
|
||
}); |
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,55 @@ | ||
.leaflet-popup-content h4.harbour, | ||
.leaflet-popup-content h4.seasonal, | ||
.leaflet-popup-content h4.pier { | ||
text-indent: 26px; | ||
} | ||
.leaflet-popup-content h4.harbour { | ||
background: url("./harbour.png") no-repeat scroll center left transparent; | ||
} | ||
.leaflet-popup-content h4.seasonal { | ||
background: url("./seasonal.png") no-repeat scroll center left transparent; | ||
} | ||
.leaflet-popup-content h4.pier { | ||
background: url("./pier.png") no-repeat scroll center left transparent; | ||
} | ||
.leaflet-popup-content .icon { | ||
display: inline-block; | ||
height: 36px; | ||
line-height: 36px; | ||
text-align: center; | ||
width: 36px; | ||
margin: 0 10px 10px 0; | ||
} | ||
.leaflet-popup-content .raw_tags { | ||
background-color: #e5e5e5; | ||
padding: 10px; | ||
} | ||
.leaflet-popup-content .phone { | ||
background: url("./phone.png") no-repeat scroll center left transparent; | ||
height: 36px; | ||
line-height: 36px; | ||
text-indent: 40px; | ||
font-size: 1.2em; | ||
} | ||
.leaflet-popup-content .info { | ||
background: white; | ||
color: black; | ||
} | ||
.leaflet-popup-content .vhf { | ||
border: 4px solid red; | ||
position: relative; | ||
font-weight: bold; | ||
font-size: 1.3em; | ||
line-height: 45px; | ||
} | ||
.leaflet-popup-content .vhf:before { | ||
content: "VHF"; | ||
left: 6px; | ||
position: absolute; | ||
top: -12px; | ||
font-size: 0.8em; | ||
} | ||
.reveal-osm-popup li strong { | ||
display: inline-block; | ||
width: 100px; | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,10 +1,5 @@ | ||
<div id="map"></div> | ||
<script type="text/javascript"> | ||
var MAP = new L.Storage.Map("map", {{ map_settings|safe }}); | ||
L.tileLayer('http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png', { | ||
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, sea marks <a href="http://openseamap.org">OpenSeaMap</a>', | ||
maxZoom: 18, | ||
minZoom: 10, | ||
zIndex: 1000 | ||
}).addTo(MAP); | ||
MAP.revealOSMControl = (new RevealOSM()).addTo(MAP); | ||
</script> |
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