Compare commits

..

3 Commits

Author SHA1 Message Date
David Molineus
a89b9abc96 Hotfix geocoder merging c13ccf55da. Also minimize libraries. 2018-02-06 17:09:15 +01:00
David Molineus
bf88bbca8c Update leaflet geocoder. 2018-02-06 16:59:33 +01:00
David Molineus
232d223eee Fix branch aliases and apply spdx license format changes. 2018-01-27 13:38:31 +01:00
9 changed files with 70 additions and 54 deletions

View File

@@ -18,7 +18,7 @@ This package contains following packages:
- [Leaflet-omnivore 0.3.4](https://github.com/mapbox/leaflet-omnivore)
- [Leaflet.loading 0.1.24](https://github.com/ebrelsford/Leaflet.loading)
- [Leaflet.Control.FullScreen 1.4.3](https://github.com/brunob/leaflet.fullscreen)
- [Leaflet Control Geocoder 1.5.5](https://github.com/perliedman/leaflet-control-geocoder)
- [Leaflet Control Geocoder 1.5.8](https://github.com/perliedman/leaflet-control-geocoder)
- [Leaflet.ExtraMarkers 1.0.6](https://github.com/coryasilva/Leaflet.ExtraMarkers)
- [leaflet.pm 0.23.1](https://github.com/codeofsumit/leaflet.pm)
- [osmtogeojson 2.2.12](https://github.com/tyrasd/osmtogeojson)

View File

@@ -49,6 +49,7 @@
background-image: url(images/geocoder.png);
background-repeat: no-repeat;
background-position: center;
cursor: pointer;
}
.leaflet-touch .leaflet-control-geocoder-icon {

View File

@@ -8,7 +8,7 @@ module.exports = {
options: {
showResultIcons: false,
collapsed: true,
expand: 'click',
expand: 'touch', // options: touch, click, anythingelse
position: 'topright',
placeholder: 'Search...',
errorMessage: 'Nothing found.',
@@ -17,7 +17,7 @@ module.exports = {
defaultMarkGeocode: true
},
includes: L.Mixin.Events,
includes: L.Evented.prototype || L.Mixin.Events,
initialize: function (options) {
L.Util.setOptions(this, options);
@@ -54,6 +54,9 @@ module.exports = {
L.DomEvent.disableClickPropagation(this._alts);
L.DomEvent.addListener(input, 'keydown', this._keydown, this);
if (this.options.geocoder.suggest) {
L.DomEvent.addListener(input, 'input', this._change, this);
}
L.DomEvent.addListener(input, 'blur', function() {
if (this.options.collapsed && !this._preventBlurCollapse) {
this._collapse();
@@ -64,22 +67,36 @@ module.exports = {
if (this.options.collapsed) {
if (this.options.expand === 'click') {
L.DomEvent.addListener(icon, 'click', function(e) {
// TODO: touch
L.DomEvent.addListener(container, 'click', function(e) {
if (e.button === 0 && e.detail !== 2) {
this._toggle();
}
}, this);
} else {
L.DomEvent.addListener(icon, 'mouseover', this._expand, this);
L.DomEvent.addListener(icon, 'mouseout', this._collapse, this);
}
else if (L.Browser.touch && this.options.expand === 'touch') {
L.DomEvent.addListener(container, 'touchstart mousedown', function(e) {
this._toggle();
e.preventDefault(); // mobile: clicking focuses the icon, so UI expands and immediately collapses
e.stopPropagation();
}, this);
}
else {
L.DomEvent.addListener(container, 'mouseover', this._expand, this);
L.DomEvent.addListener(container, 'mouseout', this._collapse, this);
this._map.on('movestart', this._collapse, this);
}
} else {
L.DomEvent.addListener(icon, 'click', function(e) {
this._geocode(e);
}, this);
this._expand();
if (L.Browser.touch) {
L.DomEvent.addListener(container, 'touchstart', function(e) {
this._geocode();
}, this);
}
else {
L.DomEvent.addListener(container, 'click', function(e) {
this._geocode();
}, this);
}
}
if (this.options.defaultMarkGeocode) {
@@ -151,15 +168,11 @@ module.exports = {
},
_geocodeResultSelected: function(result) {
if (!this.options.collapsed) {
this._clearResults();
}
this.fire('markgeocode', {geocode: result});
},
_toggle: function() {
if (this._container.className.indexOf('leaflet-control-geocoder-expanded') >= 0) {
if (L.DomUtil.hasClass(this._container, 'leaflet-control-geocoder-expanded')) {
this._collapse();
} else {
this._expand();
@@ -173,9 +186,10 @@ module.exports = {
},
_collapse: function () {
this._container.className = this._container.className.replace(' leaflet-control-geocoder-expanded', '');
L.DomUtil.removeClass(this._container, 'leaflet-control-geocoder-expanded');
L.DomUtil.addClass(this._alts, 'leaflet-control-geocoder-alternatives-minimized');
L.DomUtil.removeClass(this._errorElement, 'leaflet-control-geocoder-error');
this._input.blur(); // mobile: keyboard shouldn't stay expanded
this.fire('collapse');
},
@@ -202,6 +216,8 @@ module.exports = {
L.DomEvent.on(li, 'click', function() {
if (this.options.collapsed) {
this._collapse();
} else {
this._clearResults();
}
}, this);
};
@@ -221,7 +237,7 @@ module.exports = {
// Use mousedown and not click, since click will fire _after_ blur,
// causing the control to have collapsed and removed the items
// before the click can fire.
L.DomEvent.addListener(li, 'mousedown', mouseDownHandler, this);
L.DomEvent.addListener(li, 'mousedown touchstart', mouseDownHandler, this);
return li;
},
@@ -252,12 +268,10 @@ module.exports = {
// Up
case 38:
select(-1);
L.DomEvent.preventDefault(e);
break;
// Up
case 40:
select(1);
L.DomEvent.preventDefault(e);
break;
// Enter
case 13:
@@ -268,11 +282,12 @@ module.exports = {
} else {
this._geocode();
}
L.DomEvent.preventDefault(e);
break;
default:
}
},
_change: function(e) {
var v = this._input.value;
if (this.options.geocoder.suggest && v !== this._lastGeocode) {
if (v !== this._lastGeocode) {
clearTimeout(this._suggestTimeout);
if (v.length >= this.options.suggestMinLength) {
this._suggestTimeout = setTimeout(L.bind(function() {
@@ -283,7 +298,6 @@ module.exports = {
}
}
}
}
}),
factory: function(options) {
return new L.Control.Geocoder(options);

View File

@@ -1 +1 @@
.leaflet-control-geocoder .leaflet-control-geocoder-icon,.leaflet-control-geocoder .leaflet-control-geocoder-icon:hover,.leaflet-control-geocoder a,.leaflet-control-geocoder a:hover{border-bottom:none;display:inline-block}.leaflet-control-geocoder{border-radius:4px;background:#fff;min-width:26px;min-height:26px}.leaflet-touch .leaflet-control-geocoder{min-width:30px;min-height:30px}.leaflet-control-geocoder .leaflet-control-geocoder-alternatives a{width:inherit;height:inherit;line-height:inherit}.leaflet-control-geocoder-form{display:none;vertical-align:middle}.leaflet-control-geocoder-expanded .leaflet-control-geocoder-form{display:inline-block}.leaflet-control-geocoder-form button,.leaflet-control-geocoder-form-no-error{display:none}.leaflet-control-geocoder-form input{font-size:120%;border:0;background-color:transparent;width:246px}.leaflet-control-geocoder-icon{border-radius:4px;width:26px;height:26px;border:none;background-color:#fff;background-image:url('images/geocoder.png');background-repeat:no-repeat;background-position:center}.leaflet-touch .leaflet-control-geocoder-icon{width:30px;height:30px}.leaflet-control-geocoder-throbber .leaflet-control-geocoder-icon{background-image:url('images/throbber.gif')}.leaflet-control-geocoder-form input:focus{outline:0}.leaflet-control-geocoder-error{margin-top:8px;margin-left:8px;display:block;color:#444}.leaflet-control-geocoder-alternatives{display:block;width:272px;list-style:none;padding:0;margin:0}.leaflet-control-geocoder-alternatives-minimized{display:none;height:0}.leaflet-control-geocoder-alternatives li{white-space:nowrap;display:block;overflow:hidden;padding:5px 8px;text-overflow:ellipsis;border-bottom:1px solid #ccc;cursor:pointer}.leaflet-control-geocoder-alternatives li a,.leaflet-control-geocoder-alternatives li a:hover{width:inherit;height:inherit;line-height:inherit;background:inherit;border-radius:inherit;text-align:left}.leaflet-control-geocoder-alternatives li:last-child{border-bottom:none}.leaflet-control-geocoder-alternatives li:hover,.leaflet-control-geocoder-selected{background-color:#f5f5f5}.leaflet-control-geocoder-address-context{color:#666}
.leaflet-control-geocoder .leaflet-control-geocoder-icon,.leaflet-control-geocoder .leaflet-control-geocoder-icon:hover,.leaflet-control-geocoder a,.leaflet-control-geocoder a:hover{border-bottom:none;display:inline-block}.leaflet-control-geocoder{border-radius:4px;background:#fff;min-width:26px;min-height:26px}.leaflet-touch .leaflet-control-geocoder{min-width:30px;min-height:30px}.leaflet-control-geocoder .leaflet-control-geocoder-alternatives a{width:inherit;height:inherit;line-height:inherit}.leaflet-control-geocoder-form{display:none;vertical-align:middle}.leaflet-control-geocoder-expanded .leaflet-control-geocoder-form{display:inline-block}.leaflet-control-geocoder-form button,.leaflet-control-geocoder-form-no-error{display:none}.leaflet-control-geocoder-form input{font-size:120%;border:0;background-color:transparent;width:246px}.leaflet-control-geocoder-icon{border-radius:4px;width:26px;height:26px;border:none;background-color:#fff;background-image:url('images/geocoder.png');background-repeat:no-repeat;background-position:center;cursor:pointer}.leaflet-touch .leaflet-control-geocoder-icon{width:30px;height:30px}.leaflet-control-geocoder-throbber .leaflet-control-geocoder-icon{background-image:url('images/throbber.gif')}.leaflet-control-geocoder-form input:focus{outline:0}.leaflet-control-geocoder-error{margin-top:8px;margin-left:8px;display:block;color:#444}.leaflet-control-geocoder-alternatives{display:block;width:272px;list-style:none;padding:0;margin:0}.leaflet-control-geocoder-alternatives-minimized{display:none;height:0}.leaflet-control-geocoder-alternatives li{white-space:nowrap;display:block;overflow:hidden;padding:5px 8px;text-overflow:ellipsis;border-bottom:1px solid #ccc;cursor:pointer}.leaflet-control-geocoder-alternatives li a,.leaflet-control-geocoder-alternatives li a:hover{width:inherit;height:inherit;line-height:inherit;background:inherit;border-radius:inherit;text-align:left}.leaflet-control-geocoder-alternatives li:last-child{border-bottom:none}.leaflet-control-geocoder-alternatives li:hover,.leaflet-control-geocoder-selected{background-color:#f5f5f5}.leaflet-control-geocoder-address-context{color:#666}

File diff suppressed because one or more lines are too long

View File

@@ -21,7 +21,7 @@ The plugin supports many different data providers:
* [What3Words](http://what3words.com/)
* [Photon](http://photon.komoot.de/)
* [Mapzen Search](https://mapzen.com/projects/search)
* [HERE Geocoder API] (https://developer.here.com/rest-apis/documentation/geocoder/topics/overview.html)
* [HERE Geocoder API](https://developer.here.com/documentation/geocoder/topics/introduction.html)
The plugin can easily be extended to support other providers. Current extensions:
@@ -94,6 +94,7 @@ L.Control.Geocoder(options)
| Option | Type | Default | Description |
| --------------- | ---------------- | ----------------- | ----------- |
| collapsed | Boolean | true | Collapse control unless hovered/clicked |
| expand | String | "touch" | How to expand a collapsed control: `touch` `click` `hover` |
| position | String | "topright" | Control [position](http://leafletjs.com/reference.html#control-positions) |
| placeholder | String | "Search..." | Placeholder text for text input
| errorMessage | String | "Nothing found." | Message when no result found / geocoding error occurs |

View File

@@ -1,10 +1,10 @@
{
"name": "leaflet-control-geocoder",
"version": "1.5.5",
"version": "1.5.8",
"description": "Extendable geocoder with builtin support for Nominatim, Bing, Google, Mapbox, Photon, What3Words, MapQuest, Mapzen, HERE",
"main": "dist/Control.Geocoder.js",
"scripts": {
"prepublish": "sh ./scripts/build.sh",
"prepare": "sh ./scripts/build.sh",
"publish": "sh ./scripts/publish.sh",
"postpublish": "sh ./scripts/postpublish.sh"
},

View File

@@ -3,7 +3,7 @@
"description":"Javascript libraries for the Leaflet maps integration for Contao",
"keywords":["contao", "maps", "leaflet"],
"type":"contao-module",
"license":"LGPL-3.0+",
"license":"LGPL-3.0-or-later",
"authors":[
{
"name":"David Molineus",
@@ -27,8 +27,8 @@
},
"extra":{
"branch-alias": {
"dev-master": "1.0.x-dev",
"dev-develop": "1.1.x-dev",
"dev-master": "1.3.x-dev",
"dev-develop": "1.4.x-dev",
"dev-support/0.7.x": "0.7.x-dev"
},
"contao": {

View File

@@ -75,7 +75,7 @@ $GLOBALS['LEAFLET_LIBRARIES']['leaflet-fullscreen'] = array
$GLOBALS['LEAFLET_LIBRARIES']['leaflet-control-geocoder'] = array
(
'name' => 'Leaflet Control Geocoder',
'version' => '1.5.5',
'version' => '1.5.8',
'license' => '<a href="https://github.com/perliedman/leaflet-control-geocoder/blob/master/LICENSE" target="_blank">BSD-2-Clause</a>',
'homepage' => 'https://github.com/perliedman/leaflet-control-geocoder',
'css' => 'assets/leaflet/libs/control-geocoder/Control.Geocoder.min.css',