Commits

stefano cudini committed 5a76939 Draft

update README wih geojson example

Comments (0)

Files changed (1)

 A leaflet control that search markers/features location by cutstom property.
 With ajax/jsonp autocompletion and json fields re-mapping
 
-Tested in Leaflet 0.5.1
+Tested in Leaflet 0.6.4
 
 
 #Where
 
 other examples:
 ```
+//ajax request to search.php for retrieve elements locations
 map.addControl( new L.Control.Search({url: 'search.php?q={s}'}) );
-//ajax request to search.php for retrieve elements locations
 
+
+//jsonp request to 3rd party service, implements Geocode Searching using OSM API
 map.addControl( new L.Control.Search({
-		url: 'http://nominatim.openstreetmap.org/search?format=json&q={s}',
-		jsonpParam: 'json_callback',
-		propertyName: 'display_name',
-		propertyLoc: ['lat','lon']
-	}) );
-//jsonp request to 3rd party service, implements Geocode Searching using OSM API
+	url: 'http://nominatim.openstreetmap.org/search?format=json&q={s}',
+	jsonpParam: 'json_callback',
+	propertyName: 'display_name',
+	propertyLoc: ['lat','lon']
+}) );
+
+
+//geojson layer, search and color feature vector
+var searchControl = new L.Control.Search({layer: geojsonLayer, circleLocation:false});
+searchControl.on('search_locationfound', function(e) {
+	
+	e.layer.setStyle({fillColor: '#3f0'});
+
+}).on('search_collapsed', function(e) {
+
+	featuresLayer.eachLayer(function(layer) {
+		featuresLayer.resetStyle(layer);
+	});	
+});
+map.addControl(searchControl);
 ```