cursodsv27.htm 2.98 KB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Category" content="i3Geo Mapa interativo MMA geoprocessamento sig mobile">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<title>i3GEO - OpenLayers</title>
<script src="../classesjs/i3geo.js"></script>
<script src="../pacotes/openlayers/OpenLayers2131.js"></script>
<link rel="stylesheet" type="text/css" href="../css/black.css">
</head>
<body style='margin-left: 7px; background: white;' class=yui-skin-sam>
	<div id=i3geo>
		<div id=corpoMapa style="left: 15px; width: 700px; height: 400px; background-image: url('../imagens/i3geo1bw.jpg');"></div>
	</div>
	<div style="top: 410px; text-align: left; left: 15px;">
		<button title="Digitalizar" onclick="digitaliza()" value="i3GEOselecaopoli">
			<img src="../imagens/gisicons/boundary-edit.png" />
		</button>
		<div id="wkt" style="text-align: left; left: 15px;"></div>
	</div>
	<script>
		/************

		Exemplo de inclusao de um botao que permite digitalizar poligonos no mapa


		 ************/

		i3GEO.idioma.MOSTRASELETOR = false; //para nao mostrar as bandeiras de escolha do idioma
		i3GEO.configura.mapaRefDisplay = "none";//nao mostra o mapa de referencia
		i3GEO.mapa.TEMASINICIAIS = "_lbiomashp,_llocali";
		i3GEO.mapa.TEMASINICIAISLIGADOS = "_lbiomashp";

		function digitaliza() {
			i3GEO.eventos.cliquePerm.desativa();
			if (i3GEO.desenho.layergrafico) {
				var u = i3GEO.desenho.layergrafico.getFeaturesByAttribute(
					"origem",
					"geobahia");
				if (u
					&& u.length > 0) {
					i3GEO.desenho.layergrafico.destroyFeatures(u);
				}
				poligono.activate();
				return;
			}
			i3GEO.desenho.openlayers.inicia();
			alert("Clique no mapa para desenhar um poligono");
			poligono = new OpenLayers.Control.DrawFeature(
				i3GEO.desenho.layergrafico, OpenLayers.Handler.Polygon, {
					id : "inserePoligono",
					autoActivate : true,
					type : OpenLayers.Control.TYPE_TOOL,
					//handlerOptions: {holeModifier: "altKey"},
					callbacks : {
						done : function(feature) {
							var estilo, f, u;
							u = i3GEO.desenho.layergrafico.getFeaturesByAttribute(
								"origem",
								"geobahia");
							if (u
								&& u.length > 0) {
								i3GEO.desenho.layergrafico.destroyFeatures(u);
							}
							estilo = i3GEO.desenho.estilos["normal"];

							f = new OpenLayers.Feature.Vector(
								feature, {
									origem : "geobahia"
								}, {
									graphicName : "square",
									pointRadius : 10,
									graphicOpacity : 1,
									strokeWidth : 2,
									strokeColor : estilo.linecolor,
									fillColor : estilo.fillcolor,
									fillOpacity : 0.3
								});
							i3GEO.desenho.layergrafico.addFeatures([
								f
							]);
							i3GEO.eventos.cliquePerm.ativa();
							$i("wkt").innerHTML = f.geometry;
							poligono.deactivate();
						}
					}
				});
			i3geoOL.addControls([
				poligono
			]);
		};

		i3GEO.cria();
		i3GEO.inicia();
	</script>
</body>
</html>