Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions examples/SearchControl.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"source": [
"import os\n",
"\n",
"from ipyleaflet import Map, SearchControl\n",
"from ipyleaflet import Map, SearchControl, Marker\n",
"center = [19.1646, 72.8493]\n",
"m = Map(center=center, zoom=3)"
]
Expand All @@ -21,8 +21,10 @@
"source": [
"search = SearchControl(position=\"topleft\", \n",
" url='https://nominatim.openstreetmap.org/search?format=json&q={s}', \n",
" zoom=10,\n",
" propertyName='display_name')\n",
" zoom=5,\n",
" property_name='display_name',\n",
" marker=Marker()\n",
" )\n",
"m.add_control(search)\n",
"m"
]
Expand Down
10 changes: 7 additions & 3 deletions ipyleaflet/leaflet.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,9 +983,13 @@ class SearchControl(Control):
_model_name = Unicode('LeafletSearchControlModel').tag(sync=True)
url = Unicode().tag(sync=True, o=True)
zoom = Int(10).tag(sync=True, o=True)
propertyName = Unicode('display_name').tag(sync=True, o=True)
propertyLoc = List(['lat', 'lon']).tag(sync=True, o=True)
jsonpParam = Unicode('json_callback').tag(sync=True, o=True)
property_name = Unicode('display_name').tag(sync=True, o=True)
property_loc = List(['lat', 'lon']).tag(sync=True, o=True)
jsonp_param = Unicode('json_callback').tag(sync=True, o=True)
auto_type = Bool(False).tag(sync=True, o=True)
auto_collapse = Bool(False).tag(sync=True, o=True)
animate_location = Bool(False).tag(sync=True, o=True)
marker = Instance(Marker).tag(sync=True, **widget_serialization)


class MapStyle(Style, Widget):
Expand Down
26 changes: 6 additions & 20 deletions js/src/controls/SearchControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export class LeafletSearchControlModel extends control.LeafletControlModel {
_view_name: 'LeafletSearchControlView',
_model_name: 'LeafletSearchControlModel',
url: null,
jsonpParam: 'json_callback',
propertyName: 'display_name',
propertyLoc: ['lat','lon'],
autoType: false,
autoCollapse: false,
jsonp_param: 'json_callback',
property_name: 'display_name',
property_loc: ['lat','lon'],
auto_type: false,
auto_collapse: false,
zoom:10,
animateLocation:false,
animate_location:false,
marker: L.circleMarker([0,0],{radius:30}),
};
}
Expand All @@ -32,18 +32,4 @@ export class LeafletSearchControlView extends control.LeafletControlView{
create_obj() {
this.obj = L.control.search(this.get_options());
}

get_options() {
const options = super.get_options();
options['url'] = this.model.get('url');
options['zoom'] = this.model.get('zoom');
options['jsonpParam'] = this.model.get('jsonpParam');
options['propertyLoc'] = this.model.get('propertyLoc');
options['autoType'] = this.model.get('autoType');
options['autoCollapse'] = this.model.get('autoCollapse');
options['animateLocation'] = this.model.get('animateLocation')
options['marker'] = this.model.get('marker');
options['propertyName'] = this.model.get('propertyName')
return options;
}
}