[Cartoweb-users] new tool to the Toolbar
Pierre GIRAUD
pierre.giraud at camptocamp.com
Wed Sep 6 08:00:07 EDT 2006
Hello,
I think I know the functionnalities you are about to add to the routing
plugin. We developped some similar tools for one of our customers.
The first thing you need to know is that there is a generic way to add
tools to the toolbar. You cannot get what you want with simply adding
code in the templates.
This generic way uses the ToolProvider interface.
So, your php class that extends ClientRouting needs to implement the
ToolProvider interface.
Then, you'll have to define 4 methods (handleMainmapTool,
handleKeymapTool, handleApplicationTool, and getTools). The last one
will probably look something like :
const TOOL_ROUTING_FROM = 'routing_from';
const TOOL_ROUTING_TO = 'routing_to';
/**
* Returns the routing tools : RoutingFrom, RoutingTo
* @see ToolProvider::getTools()
* @return array of ToolDescription
*/
public function getTools() {
$toolsArray = array();
$toolsArray[] = new ToolDescription(self::TOOL_ROUTING_FROM,
true, 101);
$toolsArray[] = new ToolDescription(self::TOOL_ROUTING_TO, true,
102);
return $toolsArray;
}
That done, you should be able to see the new tools in the toolbar. To
get images within those tools, you need "routing_from.gif" and
"routing_to.gif" files in the correct directory
(plugins/routing/htdocs/gfx/).
The next step is to write the javascript methods for the tools. Edit a
new javascript file "plugins/routing/htdocs/js/dhtmlRouting.js" (loaded
in your templates) with the needed functions.
Map.prototype.routing_from = function(aDisplay) {
...
}
Hope this helps.
Don't hesitate to ask if this isn't clear or if you are not able to go
further.
Regards
Pierre
Jonathan Gillot wrote:
> hello,
>
> i'm writting a plugin to find the path between 2 point clicked on the
> map. So i must add a new tool to the toolbar what is the good method
> to do this?
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Cartoweb-users mailing list
>Cartoweb-users at lists.maptools.org
>http://lists.maptools.org/mailman/listinfo/cartoweb-users
>
>
More information about the Cartoweb-users
mailing list