<!DOCTYPE html>
<html>
<head>
<meta charset = "UTF-8">
<link type="text/css" rel="stylesheet" href="style.css" />
<title>Webforum</title>
<script src = "http://openlayers.org/api/OpenLayers.js"></script>
<script src = "http://openstreetmap.org/openlayers/OpenStreetMap.js"></script>
<script>
// globale Daten:
var map;
var vectors;
var pnr = 1;
function onFeatureSelect( evt ) {
//alert( evt.feature.ID );
// Popup erzeugen:
var html="<p>POI " + evt.feature.ID + "</p>";
var popup =
new OpenLayers.Popup.FramedCloud("featurePopup",
evt.feature.geometry.getBounds().getCenterLonLat(), // Anzeigeposition
new OpenLayers.Size(100,100), // Grösse in Pixel
html, // HTML-Code, der im Popup angezeigt
// werden soll
null,
true, // Show close box
null //onPopupClose // Function to be called on closeBox click
);
map.addPopup(popup); // Popup anzeigen
evt.feature.popup = popup; // Merken, damits später wieder gelöscht werden kann
}
function onFeatureUnselect( evt ) {
map.removePopup(evt.feature.popup); // Popup ausblenden
evt.feature.popup.destroy(); // Popup loeschen
evt.feature.popup = null;
}
// initialisierung:
function init() {
map = new OpenLayers.Map("map" );
var mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik",{layers: 'basic'});
var layerCycleMap = new OpenLayers.Layer.OSM.CycleMap("Fahrradkarte");
vectors = new OpenLayers.Layer.Vector("Vector Layer");
map.addLayers( [layerCycleMap,mapnik,vectors] );
// Controls definieren:
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
map.addControl(new OpenLayers.Control.ScaleLine());
// Point Construction control erzeugen und in map einsetzen:
var pointConstructor = new OpenLayers.Control.DrawFeature(vectors, OpenLayers.Handler.Point);
map.addControl(pointConstructor);
pointConstructor.handler.callbacks.done = function( point ) {
var poiStyle = OpenLayers.Util.extend(
{}, OpenLayers.Feature.Vector.style["default"]);
OpenLayers.Util.extend(
poiStyle, {fillColor: "green", fillOpacity:0.8, pointRadius:15});
// Punkt konstruieren:
if (pnr==1) {
var pointFeature = new OpenLayers.Feature.Vector(point, null, poiStyle );
vectors.addFeatures( [pointFeature] );
pointFeature.ID = pnr++;
alert( "Punkt eingefügt: (" + point.x + "," + point.y + ")" );
[B] var x_koordinate = point.x;
form.hiddenfeld1 = x_koordinate;
var y_koordinate = point.y;
from.hiddenfeld2 = y_koordinate;[/B]
}
}
// Control aktivieren:
pointConstructor.activate();
// Mouse Hover aktivieren:
var selectControl =
new OpenLayers.Control.SelectFeature( vectors, {hover:true});
map.addControl(selectControl);
// Control aktivieren:
selectControl.activate();
vectors.events.on({
'featureselected': onFeatureSelect,
'featureunselected': onFeatureUnselect
});
// Set initial view and scale:
var lon= 1488143.92; // Berliner HBF
var lat= 6895656.55;
var zoom= 14;
var lonLat = new OpenLayers.LonLat(lon, lat);
map.setCenter (lonLat, zoom);
// Einfügen eines POI in den Vektorlayer:
// Construct style for new POIs based on existing default style:
var poiStyle = OpenLayers.Util.extend(
{}, OpenLayers.Feature.Vector.style["default"]);
OpenLayers.Util.extend(
poiStyle, {fillColor: "red", fillOpacity:0.8, pointRadius:10});
}
</script>
</head>
<body>
<div id= "header">
<h2>WebForum</h2>
</div>
<?php include 'db_anmelde.php';
$kat_id = $_REQUEST['kat_id'];
?>
<div id= "standard">
<form action="beitrag_speichern.php?kat_id=<? echo "$kat_id";?>" method="post">
Autor:</br><select name="autor">
<?
$autor_liste = $dbh->query("SELECT name FROM autor;");
if ($autor_liste){
while ($row2 =$autor_liste->fetch(PDO::FETCH_OBJ)){
?>
<option><? echo $row2->name;?></option>
<?
}
}
?>
</select></br>
Kurzbeschreibung:</br><textarea name="kurzb" cols="50" rows="2"></textarea></br>
Beitrag:</br><textarea name="beitrag" cols="50" rows="10"></textarea></br>
[B] <INPUT type="hidden" name="hiddenfeld1">
<INPUT type="hidden" name="hiddenfeld2">[/B]
<input type="submit" name="submit" value="hinzufügen">
</form>
</br>
<body onload="init()">
<div style="width:50%; height:400px" id="map"> </div>
</br></br></br></br>
<a href="index.php">Startseite</a>
</div>
</body>
</html>