=b.length-1)L.DomUtil.addClass(b[this._tooltip.currentSelection],"search-tip-select");else if(-1==a&&this._tooltip.currentSelection<=0)this._tooltip.currentSelection=-1;else if("none"!=this._tooltip.style.display){this._tooltip.currentSelection+=a,L.DomUtil.addClass(b[this._tooltip.currentSelection],"search-tip-select"),this._input.value=b[this._tooltip.currentSelection]._text;var c=b[this._tooltip.currentSelection].offsetTop;c+b[this._tooltip.currentSelection].clientHeight>=this._tooltip.scrollTop+this._tooltip.clientHeight?this._tooltip.scrollTop=c-this._tooltip.clientHeight+b[this._tooltip.currentSelection].clientHeight:c<=this._tooltip.scrollTop&&(this._tooltip.scrollTop=c)}},_handleSubmit:function(){if(this._hideAutoType(),this.hideAlert(),this._hideTooltip(),"none"==this._input.style.display)this.expand();else if(""===this._input.value)this.collapse();else{var a=this._getLocation(this._input.value);a===!1?this.showAlert():(this.showLocation(a,this._input.value),this.fire("search_locationfound",{latlng:a,text:this._input.value,layer:a.layer?a.layer:null}))}},_getLocation:function(a){return this._recordsCache.hasOwnProperty(a)?this._recordsCache[a]:!1},showLocation:function(a,b){return this.options.zoom?this._map.setView(a,this.options.zoom):this._map.panTo(a),this._markerLoc&&(this._markerLoc.setLatLng(a),this._markerLoc.setTitle(b),this._markerLoc.show(),this.options.animateLocation&&this._markerLoc.animate()),this.options.autoCollapse&&this.collapse(),this}});var a=L.Marker.extend({includes:L.Mixin.Events,options:{radius:10,weight:3,color:"#e03",stroke:!0,fill:!1,title:"",marker:!1},initialize:function(a,b){L.setOptions(this,b),L.Marker.prototype.initialize.call(this,a,b),this._circleLoc=new L.CircleMarker(a,this.options)},onAdd:function(a){L.Marker.prototype.onAdd.call(this,a),a.addLayer(this._circleLoc),this.hide()},onRemove:function(a){L.Marker.prototype.onRemove.call(this,a),a.removeLayer(this._circleLoc)},setLatLng:function(a){return L.Marker.prototype.setLatLng.call(this,a),this._circleLoc.setLatLng(a),this},setTitle:function(a){return a=a||"",this.options.title=a,this._icon&&(this._icon.title=a),this},show:function(){return this.options.marker&&(this._icon&&(this._icon.style.display="block"),this._shadow&&(this._shadow.style.display="block")),this._circleLoc&&this._circleLoc.setStyle({fill:this.options.fill,stroke:this.options.stroke}),this},hide:function(){return this._icon&&(this._icon.style.display="none"),this._shadow&&(this._shadow.style.display="none"),this._circleLoc&&this._circleLoc.setStyle({fill:!1,stroke:!1}),this},animate:function(){var a=this._circleLoc,b=200,c=10,d=parseInt(a._radius/c),e=this.options.radius,f=2.5*a._radius,g=0;return a._timerAnimLoc=setInterval(function(){g+=.5,d+=g,f-=d,a.setRadius(f),e>f&&(clearInterval(a._timerAnimLoc),a.setRadius(e))},b),this}});L.Map.addInitHook(function(){this.options.searchControl&&(this.searchControl=L.control.search(this.options.searchControl),this.addControl(this.searchControl))}),L.control.search=function(a){return new L.Control.Search(a)}}).call(this);
\ No newline at end of file
diff --git a/bower_components/leaflet-search/dist/leaflet-search.mobile.min.css b/bower_components/leaflet-search/dist/leaflet-search.mobile.min.css
index 79dfd07..6adfa40 100644
--- a/bower_components/leaflet-search/dist/leaflet-search.mobile.min.css
+++ b/bower_components/leaflet-search/dist/leaflet-search.mobile.min.css
@@ -1,5 +1,5 @@
/*
- * Leaflet Search Control v1.4.7 - 2014-01-04
+ * Leaflet Search Control v1.5.1 - 2014-05-12
*
* Copyright 2014 Stefano Cudini
* stefano.cudini@gmail.com
diff --git a/bower_components/leaflet-search/dist/leaflet-search.mobile.src.css b/bower_components/leaflet-search/dist/leaflet-search.mobile.src.css
index 19aedd3..be556ab 100644
--- a/bower_components/leaflet-search/dist/leaflet-search.mobile.src.css
+++ b/bower_components/leaflet-search/dist/leaflet-search.mobile.src.css
@@ -1,5 +1,5 @@
/*
- * Leaflet Search Control v1.4.7 - 2014-01-04
+ * Leaflet Search Control v1.5.1 - 2014-05-12
*
* Copyright 2014 Stefano Cudini
* stefano.cudini@gmail.com
diff --git a/bower_components/leaflet-search/dist/leaflet-search.src.css b/bower_components/leaflet-search/dist/leaflet-search.src.css
index 1651c0a..ef08560 100644
--- a/bower_components/leaflet-search/dist/leaflet-search.src.css
+++ b/bower_components/leaflet-search/dist/leaflet-search.src.css
@@ -1,5 +1,5 @@
/*
- * Leaflet Search Control v1.4.7 - 2014-01-04
+ * Leaflet Search Control v1.5.1 - 2014-05-12
*
* Copyright 2014 Stefano Cudini
* stefano.cudini@gmail.com
diff --git a/bower_components/leaflet-search/dist/leaflet-search.src.js b/bower_components/leaflet-search/dist/leaflet-search.src.js
index 1bf93a3..6c7c1d1 100644
--- a/bower_components/leaflet-search/dist/leaflet-search.src.js
+++ b/bower_components/leaflet-search/dist/leaflet-search.src.js
@@ -1,5 +1,5 @@
/*
- * Leaflet Search Control v1.4.7 - 2014-01-04
+ * Leaflet Search Control v1.5.1 - 2014-05-12
*
* Copyright 2014 Stefano Cudini
* stefano.cudini@gmail.com
@@ -14,32 +14,32 @@
* git@github.com:stefanocudini/leaflet-search.git
*
*/
-
(function() {
L.Control.Search = L.Control.extend({
includes: L.Mixin.Events,
//
- // Name Data passed Description
+ // Name Data passed Description
//
//Managed Events:
- // search_locationfound {latlng, title} fired after moved and show markerLocation
- // search_collapsed {} fired after control was collapsed
+ // search_locationfound {latlng, title, layer} fired after moved and show markerLocation
+ // search_collapsed {} fired after control was collapsed
//
//Public methods:
- // setLayer() L.LayerGroup() set layer search at runtime
- // showAlert() 'Text message' Show alert message
+ // setLayer() L.LayerGroup() set layer search at runtime
+ // showAlert() 'Text message' Show alert message
//
options: {
+ wrapper: '', //container id to insert Search Control
url: '', //url for search by ajax request, ex: "search.php?q={s}"
jsonpParam: null, //jsonp param name for search by jsonp service, ex: "callback"
layer: null, //layer where search markers(is a L.LayerGroup)
callData: null, //function that fill _recordsCache, passed searching text by first param and callback in second
//TODO important! implements uniq option 'sourceData' that recognizes source type: url,array,callback or layer
//TODO implement can do research on multiple sources
- propertyName: 'title', //property in marker.options(or feature.properties for vector layer) trough filter elements in layer
- propertyLoc: 'loc', //field name for remapping location, using array: ['latname','lonname'] for select double fields(ex. ['lat','lon'] )
- //TODO implement sub property filter for propertyName,propertyLoc like this: "prop.subprop.title"
+ propertyName: 'title', //property in marker.options(or feature.properties for vector layer) trough filter elements in layer,
+ propertyLoc: 'loc', //field for remapping location, using array: ['latname','lonname'] for select double fields(ex. ['lat','lon'] )
+ // support dotted format: 'prop.subprop.title'
callTip: null, //function that return row tip html node(or html string), receive text tooltip in first param
filterJSON: null, //callback for filtering data to _recordsCache
minLength: 1, //minimal text length for autocomplete
@@ -49,6 +49,7 @@ L.Control.Search = L.Control.extend({
tooltipLimit: -1, //limit max results to show in tooltip. -1 for no limit.
tipAutoSubmit: true, //auto map panTo when click on tooltip
autoResize: true, //autoresize on input change
+ collapsed: true, //collapse search control at startup
autoCollapse: false, //collapse search control after submit(on button or on tips if enabled tipAutoSubmit)
//TODO add option for persist markerLoc after collapse!
autoCollapseTime: 1200, //delay for autoclosing alert and collapse after blur
@@ -64,7 +65,18 @@ L.Control.Search = L.Control.extend({
},
//FIXME option condition problem {autoCollapse: true, markerLocation: true} not show location
//FIXME option condition problem {autoCollapse: false }
-
+//
+//TODO important optimization!!! always append data in this._recordsCache
+// now _recordsCache content is emptied and replaced with new data founded
+// always appending data on _recordsCache give the possibility of caching ajax, jsonp and layersearch!
+//
+//TODO here insert function that search inputText FIRST in _recordsCache keys and if not find results..
+// run one of callbacks search(callData,jsonpUrl or options.layer) and run this.showTooltip
+//
+//TODO change structure of _recordsCache
+// like this: _recordsCache = {"text-key1": {loc:[lat,lng], ..other attributes.. }, {"text-key2": {loc:[lat,lng]}...}, ...}
+// in this mode every record can have a free structure of attributes, only 'loc' is required
+
initialize: function(options) {
L.Util.setOptions(this, options || {});
this._inputMinSize = this.options.text ? this.options.text.length : 10;
@@ -83,7 +95,10 @@ L.Control.Search = L.Control.extend({
this._cancel = this._createCancel(this.options.textCancel, 'search-cancel');
this._button = this._createButton(this.options.text, 'search-button');
this._alert = this._createAlert('search-alert');
-
+
+ if(this.options.collapsed===false)
+ this.expand();
+
if(this.options.circleLocation || this.options.markerLocation)
this._markerLoc = new SearchMarker([0,0], {marker: this.options.markerLocation});//see below
@@ -91,10 +106,23 @@ L.Control.Search = L.Control.extend({
map.on({
// 'layeradd': this._onLayerAddRemove,
// 'layerremove': this._onLayerAddRemove
- 'resize':this._handleAutoresize()
+ 'resize': this._handleAutoresize
}, this);
return this._container;
},
+ addTo: function (map) {
+
+ if(this.options.wrapper) {
+ this._container = this.onAdd(map);
+ this._wrapper = L.DomUtil.get(this.options.wrapper);
+ this._wrapper.style.position = 'relative';
+ this._wrapper.appendChild(this._container);
+ }
+ else
+ L.Control.prototype.addTo.call(this, map);
+
+ return this;
+ },
onRemove: function(map) {
this._recordsCache = {};
@@ -111,7 +139,22 @@ L.Control.Search = L.Control.extend({
// if( L.stamp(e.layer) != L.stamp(this._layer) )
// this.setLayer(e.layer);
// },
-
+
+ _getPath: function(obj, prop) {
+ var parts = prop.split('.'),
+ last = parts.pop(),
+ len = parts.length,
+ cur = parts[0],
+ i = 1;
+
+ if(len > 0)
+ while((obj = obj[cur]) && i < len)
+ cur = parts[i++];
+
+ if(obj)
+ return obj[last];
+ },
+
setLayer: function(layer) { //set search layer at runtime
//this.options.layer = layer; //setting this, run only this._recordsFromLayer()
this._layer = layer;
@@ -147,7 +190,7 @@ L.Control.Search = L.Control.extend({
return this;
},
- expand: function() {
+ expand: function() {
this._input.style.display = 'block';
L.DomUtil.addClass(this._container, 'search-exp');
this._input.focus();
@@ -159,12 +202,15 @@ L.Control.Search = L.Control.extend({
this._hideTooltip();
this.cancel();
this._alert.style.display = 'none';
- this._input.style.display = 'none';
this._input.blur();
- this._cancel.style.display = 'none';
- L.DomUtil.removeClass(this._container, 'search-exp');
- //this._markerLoc.hide();//maybe unuseful
- this._map.off('dragstart', this.collapse, this);
+ if(this.options.collapsed)
+ {
+ this._input.style.display = 'none';
+ this._cancel.style.display = 'none';
+ L.DomUtil.removeClass(this._container, 'search-exp');
+ //this._markerLoc.hide();//maybe unuseful
+ this._map.off('dragstart', this.collapse, this);
+ }
this.fire('search_collapsed');
return this;
},
@@ -364,18 +410,17 @@ L.Control.Search = L.Control.extend({
},
_defaultFilterJSON: function(json) { //default callback for filter data
- var jsonret = {},
+ var jsonret = {}, i,
propName = this.options.propertyName,
propLoc = this.options.propertyLoc;
if( L.Util.isArray(propLoc) )
- for(var i in json)
- jsonret[ json[i][propName] ]= L.latLng( json[i][ propLoc[0] ], json[i][ propLoc[1] ] );
+ for(i in json)
+ jsonret[ this._getPath(json[i],propName) ]= L.latLng( json[i][ propLoc[0] ], json[i][ propLoc[1] ] );
else
- for(var n in json)
- jsonret[ json[n][propName] ]= L.latLng( json[n][ propLoc ] );
- //TODO verify json[n].hasOwnProperty(propName)
- //throw new Error("propertyName '"+propName+"' not found in JSON data");
+ for(i in json)
+ jsonret[ this._getPath(json[i],propName) ]= L.latLng( this._getPath(json[i],propLoc) );
+ //TODO throw new Error("propertyName '"+propName+"' not found in JSON data");
return jsonret;
},
@@ -426,7 +471,8 @@ L.Control.Search = L.Control.extend({
},
_recordsFromLayer: function() { //return table: key,value from layer
- var retRecords = {},
+ var that = this,
+ retRecords = {},
propName = this.options.propertyName,
loc;
@@ -436,17 +482,17 @@ L.Control.Search = L.Control.extend({
if(layer instanceof L.Marker)
{
- if(layer.options.hasOwnProperty(propName))
+ if(that._getPath(layer.options,propName))
{
loc = layer.getLatLng();
loc.layer = layer;
- retRecords[ layer.options[propName] ] = loc;
+ retRecords[ that._getPath(layer.options,propName) ] = loc;
- }else if(layer.feature.properties.hasOwnProperty(propName)){
+ }else if(that._getPath(layer.feature.properties,propName)){
loc = layer.getLatLng();
loc.layer = layer;
- retRecords[ layer.feature.properties[propName] ] = loc;
+ retRecords[ that._getPath(layer.feature.properties,propName) ] = loc;
}else{
console.log("propertyName '"+propName+"' not found in marker", layer);
@@ -587,7 +633,7 @@ L.Control.Search = L.Control.extend({
L.DomUtil.addClass(this._container, 'search-load');
- if(this.options.callData) //CUSTOM SEARCH CALLBACK(USUALLY FOR AJAX SEARCHING)
+ if(this.options.callData) //CUSTOM SEARCH CALLBACK
{
that = this;
this.options.callData(inputText, function(jsonraw) {
@@ -837,7 +883,7 @@ var SearchMarker = L.Marker.extend({
}, tInt);
return this;
- }
+ }
});
L.Map.addInitHook(function () {
diff --git a/bower_components/leaflet-search/index.html b/bower_components/leaflet-search/index.html
index 7617f48..e0a81ca 100644
--- a/bower_components/leaflet-search/index.html
+++ b/bower_components/leaflet-search/index.html
@@ -37,24 +37,26 @@
Customize tooltip menu
Many options to customize the behavior
Support search in features collection
+ Render Search Box Outside the Leaflet Map
diff --git a/bower_components/leaflet-search/package.json b/bower_components/leaflet-search/package.json
index 4496e39..aec39c3 100644
--- a/bower_components/leaflet-search/package.json
+++ b/bower_components/leaflet-search/package.json
@@ -1,6 +1,6 @@
{
"name": "leaflet-search",
- "version": "1.4.7",
+ "version": "1.5.1",
"description": "Leaflet Control for searching markers/features by attribute on map or remote searching in jsonp/ajax",
"repository": {
"type": "git",
@@ -23,6 +23,7 @@
},
"devDependencies": {
"grunt": "~0.4.2",
+ "grunt-cli": "~0.1.11",
"grunt-contrib-uglify": "~0.2.7",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-clean": "~0.5.0",
diff --git a/bower_components/leaflet-search/smart.json b/bower_components/leaflet-search/smart.json
index 2045685..03567b3 100644
--- a/bower_components/leaflet-search/smart.json
+++ b/bower_components/leaflet-search/smart.json
@@ -3,6 +3,6 @@
"description": "Leaflet Control for searching markers/features by attribute on map or remote searching in jsonp/ajax",
"homepage": "http://labs.easyblog.it/maps/leaflet-search/",
"author": "Stefano Cudini ",
- "version": "1.4.7",
+ "version": "1.5.1",
"git": "https://github.com/stefanocudini/leaflet-search.git"
-}
\ No newline at end of file
+}
diff --git a/bower_components/leaflet-search/src/leaflet-search.js b/bower_components/leaflet-search/src/leaflet-search.js
index 4d603d3..538d7b4 100644
--- a/bower_components/leaflet-search/src/leaflet-search.js
+++ b/bower_components/leaflet-search/src/leaflet-search.js
@@ -1,29 +1,29 @@
-
(function() {
L.Control.Search = L.Control.extend({
includes: L.Mixin.Events,
//
- // Name Data passed Description
+ // Name Data passed Description
//
//Managed Events:
- // search_locationfound {latlng, title} fired after moved and show markerLocation
- // search_collapsed {} fired after control was collapsed
+ // search_locationfound {latlng, title, layer} fired after moved and show markerLocation
+ // search_collapsed {} fired after control was collapsed
//
//Public methods:
- // setLayer() L.LayerGroup() set layer search at runtime
- // showAlert() 'Text message' Show alert message
+ // setLayer() L.LayerGroup() set layer search at runtime
+ // showAlert() 'Text message' Show alert message
//
options: {
+ wrapper: '', //container id to insert Search Control
url: '', //url for search by ajax request, ex: "search.php?q={s}"
jsonpParam: null, //jsonp param name for search by jsonp service, ex: "callback"
layer: null, //layer where search markers(is a L.LayerGroup)
callData: null, //function that fill _recordsCache, passed searching text by first param and callback in second
//TODO important! implements uniq option 'sourceData' that recognizes source type: url,array,callback or layer
//TODO implement can do research on multiple sources
- propertyName: 'title', //property in marker.options(or feature.properties for vector layer) trough filter elements in layer
- propertyLoc: 'loc', //field name for remapping location, using array: ['latname','lonname'] for select double fields(ex. ['lat','lon'] )
- //TODO implement sub property filter for propertyName,propertyLoc like this: "prop.subprop.title"
+ propertyName: 'title', //property in marker.options(or feature.properties for vector layer) trough filter elements in layer,
+ propertyLoc: 'loc', //field for remapping location, using array: ['latname','lonname'] for select double fields(ex. ['lat','lon'] )
+ // support dotted format: 'prop.subprop.title'
callTip: null, //function that return row tip html node(or html string), receive text tooltip in first param
filterJSON: null, //callback for filtering data to _recordsCache
minLength: 1, //minimal text length for autocomplete
@@ -33,6 +33,7 @@ L.Control.Search = L.Control.extend({
tooltipLimit: -1, //limit max results to show in tooltip. -1 for no limit.
tipAutoSubmit: true, //auto map panTo when click on tooltip
autoResize: true, //autoresize on input change
+ collapsed: true, //collapse search control at startup
autoCollapse: false, //collapse search control after submit(on button or on tips if enabled tipAutoSubmit)
//TODO add option for persist markerLoc after collapse!
autoCollapseTime: 1200, //delay for autoclosing alert and collapse after blur
@@ -48,7 +49,18 @@ L.Control.Search = L.Control.extend({
},
//FIXME option condition problem {autoCollapse: true, markerLocation: true} not show location
//FIXME option condition problem {autoCollapse: false }
-
+//
+//TODO important optimization!!! always append data in this._recordsCache
+// now _recordsCache content is emptied and replaced with new data founded
+// always appending data on _recordsCache give the possibility of caching ajax, jsonp and layersearch!
+//
+//TODO here insert function that search inputText FIRST in _recordsCache keys and if not find results..
+// run one of callbacks search(callData,jsonpUrl or options.layer) and run this.showTooltip
+//
+//TODO change structure of _recordsCache
+// like this: _recordsCache = {"text-key1": {loc:[lat,lng], ..other attributes.. }, {"text-key2": {loc:[lat,lng]}...}, ...}
+// in this mode every record can have a free structure of attributes, only 'loc' is required
+
initialize: function(options) {
L.Util.setOptions(this, options || {});
this._inputMinSize = this.options.text ? this.options.text.length : 10;
@@ -67,7 +79,10 @@ L.Control.Search = L.Control.extend({
this._cancel = this._createCancel(this.options.textCancel, 'search-cancel');
this._button = this._createButton(this.options.text, 'search-button');
this._alert = this._createAlert('search-alert');
-
+
+ if(this.options.collapsed===false)
+ this.expand();
+
if(this.options.circleLocation || this.options.markerLocation)
this._markerLoc = new SearchMarker([0,0], {marker: this.options.markerLocation});//see below
@@ -75,10 +90,23 @@ L.Control.Search = L.Control.extend({
map.on({
// 'layeradd': this._onLayerAddRemove,
// 'layerremove': this._onLayerAddRemove
- 'resize':this._handleAutoresize()
+ 'resize': this._handleAutoresize
}, this);
return this._container;
},
+ addTo: function (map) {
+
+ if(this.options.wrapper) {
+ this._container = this.onAdd(map);
+ this._wrapper = L.DomUtil.get(this.options.wrapper);
+ this._wrapper.style.position = 'relative';
+ this._wrapper.appendChild(this._container);
+ }
+ else
+ L.Control.prototype.addTo.call(this, map);
+
+ return this;
+ },
onRemove: function(map) {
this._recordsCache = {};
@@ -95,7 +123,22 @@ L.Control.Search = L.Control.extend({
// if( L.stamp(e.layer) != L.stamp(this._layer) )
// this.setLayer(e.layer);
// },
-
+
+ _getPath: function(obj, prop) {
+ var parts = prop.split('.'),
+ last = parts.pop(),
+ len = parts.length,
+ cur = parts[0],
+ i = 1;
+
+ if(len > 0)
+ while((obj = obj[cur]) && i < len)
+ cur = parts[i++];
+
+ if(obj)
+ return obj[last];
+ },
+
setLayer: function(layer) { //set search layer at runtime
//this.options.layer = layer; //setting this, run only this._recordsFromLayer()
this._layer = layer;
@@ -131,7 +174,7 @@ L.Control.Search = L.Control.extend({
return this;
},
- expand: function() {
+ expand: function() {
this._input.style.display = 'block';
L.DomUtil.addClass(this._container, 'search-exp');
this._input.focus();
@@ -143,12 +186,15 @@ L.Control.Search = L.Control.extend({
this._hideTooltip();
this.cancel();
this._alert.style.display = 'none';
- this._input.style.display = 'none';
this._input.blur();
- this._cancel.style.display = 'none';
- L.DomUtil.removeClass(this._container, 'search-exp');
- //this._markerLoc.hide();//maybe unuseful
- this._map.off('dragstart', this.collapse, this);
+ if(this.options.collapsed)
+ {
+ this._input.style.display = 'none';
+ this._cancel.style.display = 'none';
+ L.DomUtil.removeClass(this._container, 'search-exp');
+ //this._markerLoc.hide();//maybe unuseful
+ this._map.off('dragstart', this.collapse, this);
+ }
this.fire('search_collapsed');
return this;
},
@@ -348,18 +394,17 @@ L.Control.Search = L.Control.extend({
},
_defaultFilterJSON: function(json) { //default callback for filter data
- var jsonret = {},
+ var jsonret = {}, i,
propName = this.options.propertyName,
propLoc = this.options.propertyLoc;
if( L.Util.isArray(propLoc) )
- for(var i in json)
- jsonret[ json[i][propName] ]= L.latLng( json[i][ propLoc[0] ], json[i][ propLoc[1] ] );
+ for(i in json)
+ jsonret[ this._getPath(json[i],propName) ]= L.latLng( json[i][ propLoc[0] ], json[i][ propLoc[1] ] );
else
- for(var n in json)
- jsonret[ json[n][propName] ]= L.latLng( json[n][ propLoc ] );
- //TODO verify json[n].hasOwnProperty(propName)
- //throw new Error("propertyName '"+propName+"' not found in JSON data");
+ for(i in json)
+ jsonret[ this._getPath(json[i],propName) ]= L.latLng( this._getPath(json[i],propLoc) );
+ //TODO throw new Error("propertyName '"+propName+"' not found in JSON data");
return jsonret;
},
@@ -410,7 +455,8 @@ L.Control.Search = L.Control.extend({
},
_recordsFromLayer: function() { //return table: key,value from layer
- var retRecords = {},
+ var that = this,
+ retRecords = {},
propName = this.options.propertyName,
loc;
@@ -420,17 +466,17 @@ L.Control.Search = L.Control.extend({
if(layer instanceof L.Marker)
{
- if(layer.options.hasOwnProperty(propName))
+ if(that._getPath(layer.options,propName))
{
loc = layer.getLatLng();
loc.layer = layer;
- retRecords[ layer.options[propName] ] = loc;
+ retRecords[ that._getPath(layer.options,propName) ] = loc;
- }else if(layer.feature.properties.hasOwnProperty(propName)){
+ }else if(that._getPath(layer.feature.properties,propName)){
loc = layer.getLatLng();
loc.layer = layer;
- retRecords[ layer.feature.properties[propName] ] = loc;
+ retRecords[ that._getPath(layer.feature.properties,propName) ] = loc;
}else{
console.log("propertyName '"+propName+"' not found in marker", layer);
@@ -571,7 +617,7 @@ L.Control.Search = L.Control.extend({
L.DomUtil.addClass(this._container, 'search-load');
- if(this.options.callData) //CUSTOM SEARCH CALLBACK(USUALLY FOR AJAX SEARCHING)
+ if(this.options.callData) //CUSTOM SEARCH CALLBACK
{
that = this;
this.options.callData(inputText, function(jsonraw) {
@@ -821,7 +867,7 @@ var SearchMarker = L.Marker.extend({
}, tInt);
return this;
- }
+ }
});
L.Map.addInitHook(function () {