[OpenLayers-Users] Customising Toolbar

Benoit PESTY tchule at hotmail.com
Wed Apr 25 11:47:43 EDT 2007


Excellent, thanks for the response.

For the search function geonames works quite well :

-----------------------------------------------------------------------------

/**
* Callback called when a result is found
* Affiche le résultat dans "resultDiv".
*/
	function getLocation(jData) {
		if (jData == null) {
			return;
		}

		var html = '';
		var geonames = jData.geonames;
		for (i=0;i< geonames.length;i++) {
			var name = geonames[i];
			html = html + '<a href="javascript:changezoom(' + name.lng + ',' + 
name.lat + ',4);">' + name.name + ', '+ name.adminName1 +  '</a><br/>';
		}
		document.getElementById('resultDiv').innerHTML = html;
	}

	/**
	 * Search for a place
	 */
	function search() {
		request = 'http://ws.geonames.org/searchJSON?q=' +  
encodeURIComponent(document.getElementById('q').value)  + 
'&maxRows=6&country=FR&lang=FR&fclass=A&callback=getLocation';
		aObj = new JSONscriptRequest(request);
		aObj.buildScriptTag();
		aObj.addScriptTag();
	}


-----------------------------------------------------------------------------


Tchule.


>From: "Cicconetti, Bob" <BCicconetti at dnr.state.md.us>
>To: "Benoit PESTY" <tchule at hotmail.com>,<users at openlayers.org>
>Subject: RE: [OpenLayers-Users] Customising Toolbar
>Date: Wed, 25 Apr 2007 10:43:26 -0400
>
>This may not be the best way, but here's how I did it:
>
>1) Add your tools to the control in your html file.
>
>   // Extend the edit tool bar to allow deleting features, and gather
>   // info about them.
>   var selectTool = new OpenLayers.Control.SelectFeature(vlayer,
>   	{
>	onSelect:feature_info,
>	onUnselect:clear_feature_info
>	});
>
>   var deleteTool = new OpenLayers.Control.SelectFeature(vlayer,
>         {
>	onSelect:deleteFeature,
>	onUnselect:clear_feature_info
>	});
>
>   var editToolBar = new OpenLayers.Control.EditingToolbar(vlayer);
>
>   var myControls = [ selectTool, deleteTool ];
>   // Fun with gimp. Be sure to use patched style.css.
>   myControls[0].displayClass = 'olControlSelectFeature';
>   myControls[1].displayClass = 'olControlDeleteFeature';
>
>   editToolBar.addControls(myControls);
>   map.addControl(editToolBar);
>
>
>2) Increase the size of the editing toolbar in style.css. 70 extra
>pixels may not be exact, but it works for me :) :
>
>.olControlEditingToolbar  {
>     float:right;
>     right: 0px;
>     height: 30px;
>     width: 270px;
>}
>
>3) Add your icons to the style.css
>
>.olControlEditingToolbar .olControlSelectFeatureItemInactive {
>   background-image: url("img/info_off.png");
>}
>.olControlEditingToolbar .olControlSelectFeatureItemActive {
>   background-image: url("img/info_on.png");
>}
>.olControlEditingToolbar .olControlDeleteFeatureItemInactive {
>   background-image: url("img/delete_off.png");
>}
>.olControlEditingToolbar .olControlDeleteFeatureItemActive {
>   background-image: url("img/delete_on.png");
>}
>
>4) Make your new icons.
>
>If you find a good search method, let me know, that's next on my to-do
>list after modding LayerSwitcher to turn on and off layers from a single
>WMS server.
>
>R C
>
> > -----Original Message-----
> > From: users-bounces at openlayers.org
>[mailto:users-bounces at openlayers.org]
> > On Behalf Of Benoit PESTY
> > Sent: Wednesday, April 25, 2007 10:26 AM
> > To: users at openlayers.org
> > Subject: [OpenLayers-Users] Customising Toolbar
> >
> > Hello,
> >
> > I'm developping a little application using OpenLayers and Mapserver
>and
> > I've
> > found OpenLayers very promising.
> >
> > I'm manager to do a few things I needed thanks to the examples :
> > - Show different WMS layers
> > - Add the drawing tools and a vector layer
> > - Get a feature info when clicking on the map
> > - Link the map with a place search function (using geonames and
>proj.js
> > because i'm in EPSG:27572
> >
> > What I would like to do now is to add 2 icons on the (Editing)Toolbar
>and
> > change the fonctionnalities depending on the selected icon. One icon
>to
> > show
> > info about a feature and one icon to select the feature from a base
>layer
> > and add it to my vector layer (in order to add the polygon to the
>already
> > drawn polygons).
> > My javascript abilities are a little limited and i'd like to find a
>clean
> > way to do this without breaking the
> > EditingToolbar.js file.

_________________________________________________________________
Don’t quit your job – Take Classes Online and Earn your Degree in 1 year. 
Start Today! 
http://www.classesusa.com/clickcount.cfm?id=866146&goto=http%3A%2F%2Fwww.classesusa.com%2Ffeaturedschools%2Fonlinedegreesmp%2Fform-dyn1.html%3Fsplovr%3D866144




More information about the Users mailing list