Ciao Ragazzi,
premetto che è la prima volta che programmo in javascript e che mi iscrivo ad un forum (infatti mi sono fatto 1000 paranoie sul titolo del thread ). Devo realizzare un'applicazione GeoExt in javascript per effettuare il click 'n point su una mappa georeferenziata. Scaricando dal sito di GeoExt ho trovato un esempio che fa al caso mio, al quale però dovrei aggiungere un tasto che cancella le linee o poligoni, disegnati sulla mappa. Penso che per voi sia una cosa molto semplice ma per me non lo è!!!Inoltre se mi diceste anche come farmi restituire le coordinate della mappa e come salvarle su file vi sarei molto grato.

Vi allego il codice.

* Create a toolbar with GeoExt Actions.
*/

Ext.onReady(function() {
Ext.QuickTips.init();

var map = new OpenLayers.Map();
var wms = new OpenLayers.Layer.WMS(
"Global Imagery",
"http://maps.opengeo.org/geowebcache/service/wms",
{layers: "bluemarble"}
);
var vector = new OpenLayers.Layer.Vector("vector");
map.addLayers([wms, vector]);

var ctrl, toolbarItems = [], action, actions = {};

// ZoomToMaxExtent control, a "button" control
action = new GeoExt.Action({
control: new OpenLayers.Control.ZoomToMaxExtent(),
map: map,
text: "max extent",
tooltip: "zoom to max extent"
});
actions["max_extent"] = action;
toolbarItems.push(action);
toolbarItems.push("-");

// Navigation control and DrawFeature controls
// in the same toggle group
action = new GeoExt.Action({
text: "nav",
control: new OpenLayers.Control.Navigation(),
map: map,
// button options
toggleGroup: "draw",
allowDepress: false,
pressed: true,
tooltip: "navigate",
// check item options
group: "draw",
checked: true
});
actions["nav"] = action;
toolbarItems.push(action);

action = new GeoExt.Action({
text: "draw poly",
control: new OpenLayers.Control.DrawFeature(
vector, OpenLayers.Handler.Polygon
),
map: map,
// button options
toggleGroup: "draw",
allowDepress: false,
tooltip: "draw polygon",
// check item options
group: "draw"
});
actions["draw_poly"] = action;
toolbarItems.push(action);

action = new GeoExt.Action({
text: "draw line",
control: new OpenLayers.Control.DrawFeature(
vector, OpenLayers.Handler.Path
),
map: map,
// button options
toggleGroup: "draw",
allowDepress: false,
tooltip: "draw line",
// check item options
group: "draw"
});
actions["draw_line"] = action;
toolbarItems.push(action);
toolbarItems.push("-");

// SelectFeature control, a "toggle" control
action = new GeoExt.Action({
text: "select",
control: new OpenLayers.Control.SelectFeature(vector, {
type: OpenLayers.Control.TYPE_TOGGLE,
hover: true
}),
map: map,
// button options
enableToggle: true,
tooltip: "select feature"
});
actions["select"] = action;
toolbarItems.push(action);
toolbarItems.push("-");

// Navigation history - two "button" controls
ctrl = new OpenLayers.Control.NavigationHistory();
map.addControl(ctrl);

action = new GeoExt.Action({
text: "previous",
control: ctrl.previous,
disabled: true,
tooltip: "previous in history"
});
actions["previous"] = action;
toolbarItems.push(action);

action = new GeoExt.Action({
text: "next",
control: ctrl.next,
disabled: true,
tooltip: "next in history"
});
actions["next"] = action;
toolbarItems.push(action);
toolbarItems.push("->");

// Reuse the GeoExt.Action objects created above
// as menu items
toolbarItems.push({
text: "menu",
menu: new Ext.menu.Menu({
items: [
// ZoomToMaxExtent
actions["max_extent"],
// Nav
new Ext.menu.CheckItem(actions["nav"]),
// Draw poly
new Ext.menu.CheckItem(actions["draw_poly"]),
// Draw line
new Ext.menu.CheckItem(actions["draw_line"]),
// Select control
new Ext.menu.CheckItem(actions["select"]),
// Navigation history control
actions["previous"],
actions["next"]
]
})
});

var mapPanel = new GeoExt.MapPanel({
renderTo: "mappanel",
height: 400,
width: 600,
map: map,
center: new OpenLayers.LonLat(5, 45),
zoom: 4,
tbar: toolbarItems
});
});


e l'html associato

<html>
<head>
<title>GeoExt Toolbar Example</title>

<script type="text/javascript" src="http://extjs.cachefly.net/ext-2.2.1/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="http://extjs.cachefly.net/ext-2.2.1/ext-all.js"></script>
<link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/examples/shared/examples.css" />
<script src="http://www.openlayers.org/api/2.9/OpenLayers.js"></script>
<script type="text/javascript" src="../script/GeoExt.js"></script>

<script type="text/javascript" src="toolbar.js"></script>

<style type="text/css">
/* work around an Ext bug that makes the rendering
of menu items not as one would expect */
.ext-ie .x-menu-item-icon {
left: -24px;
}
.ext-strict .x-menu-item-icon {
left: 3px;
}
.ext-ie6 .x-menu-item-icon {
left: -24px;
}
.ext-ie7 .x-menu-item-icon {
left: -24px;
}
</style>
</head>
<body>
<h1>OpenLayers controls in an Ext toolbar</h1>



This example shows how to add OpenLayers controls in an Ext toolbar.
GeoExt provides the GeoExt.Action class for adapating a control to an
object that can be inserted in a toolbar or in a menu.</p>



The js is not minified so it is readable. See toolbar.js.</p>

<div id="mappanel"></div>
</body>
</html>

Grazie in anticipo e mi scuso ancora, ma ripeto, non ho mai scritto su un forum.