forked from Snck3rs/contao-leaflet-libraries
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a89b9abc96 | ||
|
|
bf88bbca8c | ||
|
|
232d223eee |
@@ -18,7 +18,7 @@ This package contains following packages:
|
|||||||
- [Leaflet-omnivore 0.3.4](https://github.com/mapbox/leaflet-omnivore)
|
- [Leaflet-omnivore 0.3.4](https://github.com/mapbox/leaflet-omnivore)
|
||||||
- [Leaflet.loading 0.1.24](https://github.com/ebrelsford/Leaflet.loading)
|
- [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.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.ExtraMarkers 1.0.6](https://github.com/coryasilva/Leaflet.ExtraMarkers)
|
||||||
- [leaflet.pm 0.23.1](https://github.com/codeofsumit/leaflet.pm)
|
- [leaflet.pm 0.23.1](https://github.com/codeofsumit/leaflet.pm)
|
||||||
- [osmtogeojson 2.2.12](https://github.com/tyrasd/osmtogeojson)
|
- [osmtogeojson 2.2.12](https://github.com/tyrasd/osmtogeojson)
|
||||||
|
|||||||
@@ -49,6 +49,7 @@
|
|||||||
background-image: url(images/geocoder.png);
|
background-image: url(images/geocoder.png);
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.leaflet-touch .leaflet-control-geocoder-icon {
|
.leaflet-touch .leaflet-control-geocoder-icon {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ module.exports = {
|
|||||||
options: {
|
options: {
|
||||||
showResultIcons: false,
|
showResultIcons: false,
|
||||||
collapsed: true,
|
collapsed: true,
|
||||||
expand: 'click',
|
expand: 'touch', // options: touch, click, anythingelse
|
||||||
position: 'topright',
|
position: 'topright',
|
||||||
placeholder: 'Search...',
|
placeholder: 'Search...',
|
||||||
errorMessage: 'Nothing found.',
|
errorMessage: 'Nothing found.',
|
||||||
@@ -17,7 +17,7 @@ module.exports = {
|
|||||||
defaultMarkGeocode: true
|
defaultMarkGeocode: true
|
||||||
},
|
},
|
||||||
|
|
||||||
includes: L.Mixin.Events,
|
includes: L.Evented.prototype || L.Mixin.Events,
|
||||||
|
|
||||||
initialize: function (options) {
|
initialize: function (options) {
|
||||||
L.Util.setOptions(this, options);
|
L.Util.setOptions(this, options);
|
||||||
@@ -54,6 +54,9 @@ module.exports = {
|
|||||||
L.DomEvent.disableClickPropagation(this._alts);
|
L.DomEvent.disableClickPropagation(this._alts);
|
||||||
|
|
||||||
L.DomEvent.addListener(input, 'keydown', this._keydown, this);
|
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() {
|
L.DomEvent.addListener(input, 'blur', function() {
|
||||||
if (this.options.collapsed && !this._preventBlurCollapse) {
|
if (this.options.collapsed && !this._preventBlurCollapse) {
|
||||||
this._collapse();
|
this._collapse();
|
||||||
@@ -64,22 +67,36 @@ module.exports = {
|
|||||||
|
|
||||||
if (this.options.collapsed) {
|
if (this.options.collapsed) {
|
||||||
if (this.options.expand === 'click') {
|
if (this.options.expand === 'click') {
|
||||||
L.DomEvent.addListener(icon, 'click', function(e) {
|
L.DomEvent.addListener(container, 'click', function(e) {
|
||||||
// TODO: touch
|
|
||||||
if (e.button === 0 && e.detail !== 2) {
|
if (e.button === 0 && e.detail !== 2) {
|
||||||
this._toggle();
|
this._toggle();
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
} else {
|
}
|
||||||
L.DomEvent.addListener(icon, 'mouseover', this._expand, this);
|
else if (L.Browser.touch && this.options.expand === 'touch') {
|
||||||
L.DomEvent.addListener(icon, 'mouseout', this._collapse, this);
|
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);
|
this._map.on('movestart', this._collapse, this);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
L.DomEvent.addListener(icon, 'click', function(e) {
|
|
||||||
this._geocode(e);
|
|
||||||
}, this);
|
|
||||||
this._expand();
|
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) {
|
if (this.options.defaultMarkGeocode) {
|
||||||
@@ -151,15 +168,11 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_geocodeResultSelected: function(result) {
|
_geocodeResultSelected: function(result) {
|
||||||
if (!this.options.collapsed) {
|
|
||||||
this._clearResults();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.fire('markgeocode', {geocode: result});
|
this.fire('markgeocode', {geocode: result});
|
||||||
},
|
},
|
||||||
|
|
||||||
_toggle: function() {
|
_toggle: function() {
|
||||||
if (this._container.className.indexOf('leaflet-control-geocoder-expanded') >= 0) {
|
if (L.DomUtil.hasClass(this._container, 'leaflet-control-geocoder-expanded')) {
|
||||||
this._collapse();
|
this._collapse();
|
||||||
} else {
|
} else {
|
||||||
this._expand();
|
this._expand();
|
||||||
@@ -173,9 +186,10 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_collapse: function () {
|
_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.addClass(this._alts, 'leaflet-control-geocoder-alternatives-minimized');
|
||||||
L.DomUtil.removeClass(this._errorElement, 'leaflet-control-geocoder-error');
|
L.DomUtil.removeClass(this._errorElement, 'leaflet-control-geocoder-error');
|
||||||
|
this._input.blur(); // mobile: keyboard shouldn't stay expanded
|
||||||
this.fire('collapse');
|
this.fire('collapse');
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -188,21 +202,23 @@ module.exports = {
|
|||||||
_createAlt: function(result, index) {
|
_createAlt: function(result, index) {
|
||||||
var li = L.DomUtil.create('li', ''),
|
var li = L.DomUtil.create('li', ''),
|
||||||
a = L.DomUtil.create('a', '', li),
|
a = L.DomUtil.create('a', '', li),
|
||||||
icon = this.options.showResultIcons && result.icon ? L.DomUtil.create('img', '', a) : null,
|
icon = this.options.showResultIcons && result.icon ? L.DomUtil.create('img', '', a) : null,
|
||||||
text = result.html ? undefined : document.createTextNode(result.name),
|
text = result.html ? undefined : document.createTextNode(result.name),
|
||||||
mouseDownHandler = function mouseDownHandler(e) {
|
mouseDownHandler = function mouseDownHandler(e) {
|
||||||
// In some browsers, a click will fire on the map if the control is
|
// In some browsers, a click will fire on the map if the control is
|
||||||
// collapsed directly after mousedown. To work around this, we
|
// collapsed directly after mousedown. To work around this, we
|
||||||
// wait until the click is completed, and _then_ collapse the
|
// wait until the click is completed, and _then_ collapse the
|
||||||
// control. Messy, but this is the workaround I could come up with
|
// control. Messy, but this is the workaround I could come up with
|
||||||
// for #142.
|
// for #142.
|
||||||
this._preventBlurCollapse = true;
|
this._preventBlurCollapse = true;
|
||||||
L.DomEvent.stop(e);
|
L.DomEvent.stop(e);
|
||||||
this._geocodeResultSelected(result);
|
this._geocodeResultSelected(result);
|
||||||
L.DomEvent.on(li, 'click', function() {
|
L.DomEvent.on(li, 'click', function() {
|
||||||
if (this.options.collapsed) {
|
if (this.options.collapsed) {
|
||||||
this._collapse();
|
this._collapse();
|
||||||
}
|
} else {
|
||||||
|
this._clearResults();
|
||||||
|
}
|
||||||
}, this);
|
}, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -221,7 +237,7 @@ module.exports = {
|
|||||||
// Use mousedown and not click, since click will fire _after_ blur,
|
// Use mousedown and not click, since click will fire _after_ blur,
|
||||||
// causing the control to have collapsed and removed the items
|
// causing the control to have collapsed and removed the items
|
||||||
// before the click can fire.
|
// before the click can fire.
|
||||||
L.DomEvent.addListener(li, 'mousedown', mouseDownHandler, this);
|
L.DomEvent.addListener(li, 'mousedown touchstart', mouseDownHandler, this);
|
||||||
|
|
||||||
return li;
|
return li;
|
||||||
},
|
},
|
||||||
@@ -252,12 +268,10 @@ module.exports = {
|
|||||||
// Up
|
// Up
|
||||||
case 38:
|
case 38:
|
||||||
select(-1);
|
select(-1);
|
||||||
L.DomEvent.preventDefault(e);
|
|
||||||
break;
|
break;
|
||||||
// Up
|
// Up
|
||||||
case 40:
|
case 40:
|
||||||
select(1);
|
select(1);
|
||||||
L.DomEvent.preventDefault(e);
|
|
||||||
break;
|
break;
|
||||||
// Enter
|
// Enter
|
||||||
case 13:
|
case 13:
|
||||||
@@ -268,19 +282,19 @@ module.exports = {
|
|||||||
} else {
|
} else {
|
||||||
this._geocode();
|
this._geocode();
|
||||||
}
|
}
|
||||||
L.DomEvent.preventDefault(e);
|
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
var v = this._input.value;
|
},
|
||||||
if (this.options.geocoder.suggest && v !== this._lastGeocode) {
|
_change: function(e) {
|
||||||
clearTimeout(this._suggestTimeout);
|
var v = this._input.value;
|
||||||
if (v.length >= this.options.suggestMinLength) {
|
if (v !== this._lastGeocode) {
|
||||||
this._suggestTimeout = setTimeout(L.bind(function() {
|
clearTimeout(this._suggestTimeout);
|
||||||
this._geocode(true);
|
if (v.length >= this.options.suggestMinLength) {
|
||||||
}, this), this.options.suggestTimeout);
|
this._suggestTimeout = setTimeout(L.bind(function() {
|
||||||
} else {
|
this._geocode(true);
|
||||||
this._clearResults();
|
}, this), this.options.suggestTimeout);
|
||||||
}
|
} else {
|
||||||
|
this._clearResults();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1279,4 +1293,4 @@ module.exports = {
|
|||||||
|
|
||||||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||||
},{}]},{},[12])(12)
|
},{}]},{},[12])(12)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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
@@ -21,7 +21,7 @@ The plugin supports many different data providers:
|
|||||||
* [What3Words](http://what3words.com/)
|
* [What3Words](http://what3words.com/)
|
||||||
* [Photon](http://photon.komoot.de/)
|
* [Photon](http://photon.komoot.de/)
|
||||||
* [Mapzen Search](https://mapzen.com/projects/search)
|
* [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:
|
The plugin can easily be extended to support other providers. Current extensions:
|
||||||
|
|
||||||
@@ -94,6 +94,7 @@ L.Control.Geocoder(options)
|
|||||||
| Option | Type | Default | Description |
|
| Option | Type | Default | Description |
|
||||||
| --------------- | ---------------- | ----------------- | ----------- |
|
| --------------- | ---------------- | ----------------- | ----------- |
|
||||||
| collapsed | Boolean | true | Collapse control unless hovered/clicked |
|
| 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) |
|
| position | String | "topright" | Control [position](http://leafletjs.com/reference.html#control-positions) |
|
||||||
| placeholder | String | "Search..." | Placeholder text for text input
|
| placeholder | String | "Search..." | Placeholder text for text input
|
||||||
| errorMessage | String | "Nothing found." | Message when no result found / geocoding error occurs |
|
| errorMessage | String | "Nothing found." | Message when no result found / geocoding error occurs |
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "leaflet-control-geocoder",
|
"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",
|
"description": "Extendable geocoder with builtin support for Nominatim, Bing, Google, Mapbox, Photon, What3Words, MapQuest, Mapzen, HERE",
|
||||||
"main": "dist/Control.Geocoder.js",
|
"main": "dist/Control.Geocoder.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "sh ./scripts/build.sh",
|
"prepare": "sh ./scripts/build.sh",
|
||||||
"publish": "sh ./scripts/publish.sh",
|
"publish": "sh ./scripts/publish.sh",
|
||||||
"postpublish": "sh ./scripts/postpublish.sh"
|
"postpublish": "sh ./scripts/postpublish.sh"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"description":"Javascript libraries for the Leaflet maps integration for Contao",
|
"description":"Javascript libraries for the Leaflet maps integration for Contao",
|
||||||
"keywords":["contao", "maps", "leaflet"],
|
"keywords":["contao", "maps", "leaflet"],
|
||||||
"type":"contao-module",
|
"type":"contao-module",
|
||||||
"license":"LGPL-3.0+",
|
"license":"LGPL-3.0-or-later",
|
||||||
"authors":[
|
"authors":[
|
||||||
{
|
{
|
||||||
"name":"David Molineus",
|
"name":"David Molineus",
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
},
|
},
|
||||||
"extra":{
|
"extra":{
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "1.0.x-dev",
|
"dev-master": "1.3.x-dev",
|
||||||
"dev-develop": "1.1.x-dev",
|
"dev-develop": "1.4.x-dev",
|
||||||
"dev-support/0.7.x": "0.7.x-dev"
|
"dev-support/0.7.x": "0.7.x-dev"
|
||||||
},
|
},
|
||||||
"contao": {
|
"contao": {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ $GLOBALS['LEAFLET_LIBRARIES']['leaflet-fullscreen'] = array
|
|||||||
$GLOBALS['LEAFLET_LIBRARIES']['leaflet-control-geocoder'] = array
|
$GLOBALS['LEAFLET_LIBRARIES']['leaflet-control-geocoder'] = array
|
||||||
(
|
(
|
||||||
'name' => 'Leaflet Control Geocoder',
|
'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>',
|
'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',
|
'homepage' => 'https://github.com/perliedman/leaflet-control-geocoder',
|
||||||
'css' => 'assets/leaflet/libs/control-geocoder/Control.Geocoder.min.css',
|
'css' => 'assets/leaflet/libs/control-geocoder/Control.Geocoder.min.css',
|
||||||
|
|||||||
Reference in New Issue
Block a user