x

Ranking in Pop Up einbauen?


Geschrieben von elpiojo_ (Gast) am 16. August 2012 15:14:01: [flux]

Hallo, tut mir leid das ich wieder mal nervig sein muss, aber ich hab mal eine frage, besteht die möglichkeit ein rating in ein pop up einzubauen? gibt es dazu vl beispiele oder weiß wer wo man da ansetzen muss um es einzubinden? hab bisher leider nichts dazu gefuden. aktuell hab ich 3 datein meine map.html wo die karte generiert wird, mein pop up datei hier werden die daten aus der datenbank gelesen und im pop up dargstellt und eine rating seite die ich gern ins pop up einbauen möchte.

map.html

<html>
<head>
<!--␣OpenLayers␣core␣js␣-->
<script␣src="http://www.openlayers.org/api/OpenLayers.js"></script>
<!--␣OpenStreetMap␣base␣layer␣js␣-->
<script
src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js">
</script>
<script␣src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&mkt=en-us">
</script>
<script␣type="text/javascript">
var␣map,␣selectControl,␣selectedFeature,␣jumptolonlat;
function␣onPopupClose(evt)␣{
selectControl.unselect(selectedFeature);
}
function␣onFeatureSelect(feature)␣{
selectedFeature␣=␣feature;
var␣tags␣=␣feature.attributes;
var␣infoHtml␣=␣"<table>";
for␣(var␣key␣in␣tags)␣{
infoHtml␣+=␣"<tr><td>"␣+␣tags[key]␣+␣"</td></tr>";
}
infoHtml␣+=␣"</table>";
popup␣=␣new␣OpenLayers.Popup.FramedCloud("chicken",
feature.geometry.getBounds().getCenterLonLat(),
null,
infoHtml,
null,␣true,␣onPopupClose);
feature.popup␣=␣popup;
map.addPopup(popup);
}
function␣onFeatureUnselect(feature)␣{
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup␣=␣null;
}
function␣jumptolonlat(lon,lat){
var␣LonLat␣=␣new␣OpenLayers.LonLat(lon,lat).transform(new␣OpenLayers.Projection("EPSG:4326"),map.getProjectionObject());
map.setCenter(LonLat,17);
}
function␣init()␣{
//set␣up␣projections
//␣World␣Geodetic␣System␣1984␣projection
var␣WGS84␣=␣new␣OpenLayers.Projection("EPSG:4326");
//␣WGS84␣Google␣Mercator␣projection
var␣WGS84_google_mercator␣=␣new␣OpenLayers.Projection("EPSG:900913");
//Initialize␣the␣map
//creates␣a␣new␣openlayers␣map␣in␣the␣<div>␣html␣element␣id␣map
map␣=␣new␣OpenLayers.Map␣("map",␣{
controls:[
//allows␣the␣user␣pan␣ability
new␣OpenLayers.Control.Navigation(),
//displays␣the␣pan/zoom␣tools
new␣OpenLayers.Control.PanZoom(),
//displays␣a␣layer␣switcher
new␣OpenLayers.Control.LayerSwitcher(),
//displays␣the␣mouse␣position's␣coordinates␣in␣a␣<div>␣html␣element␣with
new␣OpenLayers.Control.MousePosition({
div:document.getElementById("coordinates")
}),
],
projection:␣WGS84_google_mercator,
displayProjection:␣WGS84
}␣);
//base␣layers
var␣apiKey␣=␣"Ap3i15CGW7YGzZCAkHqKmf3pVxGwDTAd0NLywcxTH3g71vWW1GgLqcD56B_deegZ";
var␣road␣=␣new␣OpenLayers.Layer.Bing({
name:␣"Road",
key:␣apiKey,
type:␣"Road",
sphericalMercator:␣true
});
var␣stmk␣=␣new␣OpenLayers.Layer.WMS(␣"stmk",␣"http://129.27.89.66/cgi-bin/mapserv?",
{␣map:␣"F:/ms4w/Apache/htdocs/student/master_geom/hp/map.map",␣layers:␣"stmk",␣transparent:␣"true"},
{
isBaseLayer:␣false,
sphericalMercator:␣true,
singleTile:␣true,
opacity:0.8
});
var␣offen␣=␣new␣OpenLayers.Layer.Vector("offen",␣{
projection:␣new␣OpenLayers.Projection("EPSG:4326"),
isBaseLayer:␣false,
opacity:0.8,
strategies:␣[new␣OpenLayers.Strategy.BBOX({resFactor:␣1.1})],
protocol:␣new␣OpenLayers.Protocol.HTTP({
url:␣"offen.php",
format:␣new␣OpenLayers.Format.Text()
})
});
var␣pois␣=␣new␣OpenLayers.Layer.Vector("POIs",␣{
projection:␣new␣OpenLayers.Projection("EPSG:4326"),
isBaseLayer:␣false,
opacity:0.8,
strategies:␣[new␣OpenLayers.Strategy.BBOX({resFactor:␣1.1})],
protocol:␣new␣OpenLayers.Protocol.HTTP({
url:␣"allebetriebe.php",
format:␣new␣OpenLayers.Format.Text()
})
});
map.addLayers([road,␣stmk,␣offen,␣pois]);
var␣pop␣=␣{␣hover:␣false,␣onSelect:␣onFeatureSelect,␣onUnselect:␣onFeatureUnselect␣};
selectControl␣=␣new␣OpenLayers.Control.SelectFeature([pois,offen],␣pop);
map.addControl(selectControl);
selectControl.activate();
//␣map␣extent
var␣mapextent␣=␣new␣OpenLayers.Bounds(15.39633,␣46.61470,␣15.56113,␣46.72708).transform(WGS84,␣map.getProjectionObject());
if␣(!map.getCenter())␣{map.zoomToExtent(mapextent);}
//␣Interaction;␣not␣needed␣for␣initial␣display.
}
</script>
</head>
<body␣onload="init()">
<div␣id="map"␣style="width:700px;␣height:700px;"></div>
<div␣id="coordinates"></div>
<input␣type="text"␣onkeyup="searchFor(this.value);"/>
<div␣id="ergebnis"></div>
</body>
</html>

pop up

$conn␣=␣pg_connect("host=$host␣port=$port␣dbname=$dbname␣user=$user␣password=$password");
$bbx␣=␣$_POST["bbox"]␣;
$array␣=␣explode(",",$bbx);
$ble␣=␣$array[0]␣;
$bbo␣=␣$array[1]␣;
$bri␣=␣$array[2]␣;
$bto␣=␣$array[3]␣;
$betriebe␣=␣"SELECT␣name,␣homepage,␣telefon,␣breite,␣laenge␣FROM␣betriebe";
$result␣=␣pg_query($conn,␣$betriebe);
$header␣=␣"point\ttitle\tdescription\ticon\n"␣;
echo␣$header␣;
while($row␣=␣pg_fetch_object($result))
{
$daten␣=␣$row->breite.",".$row->laenge."\t<b>".$row->name."</b>\t"."Homepage&nbsp;".$row->homepage."<br>Telefon&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$row->telefon."\t"."http://www.openlayers.org/dev/img/marker.png\n";
echo␣$daten␣;
}
pg_close($conn);
?>

rating

$conn␣=␣pg_connect("host=$host␣port=$port␣dbname=$dbname␣user=$user␣password=$password");
$voted␣=␣pg_escape_string($_GET['voted']);
$id␣=␣pg_escape_string($_GET['id']);
$mode␣=␣($_GET['mode']);
if␣((␣$mode=="vote")␣&&␣($voted␣>=␣"1"␣and␣$voted␣<="5"))
{
if(isset($_COOKIE[voted]))
{
Echo␣"Sorry␣You␣have␣already␣ranked␣that␣site␣<p>";
}
else
{
//Then␣we␣update␣the␣voting␣information␣by␣adding␣1␣to␣the␣total␣votes␣and␣adding␣their␣vote␣(1,2,3,etc)␣to␣the␣total␣rating
$sql␣=␣"UPDATE␣vote␣SET␣total␣=␣total+$voted,␣votes␣=␣votes+1␣WHERE␣id␣=␣$id";
pg_query($conn,␣$sql);
Echo␣"Your␣vote␣has␣been␣cast␣<p>";
}
}
//We␣only␣run␣this␣code␣if␣the␣user␣has␣just␣clicked␣a␣voting␣link
//Then␣we␣update␣the␣voting␣information␣by␣adding␣1␣to␣the␣total␣votes␣and␣adding␣their␣vote␣(1,2,3,etc)␣to␣the␣total␣rating
//Puts␣SQL␣Data␣into␣an␣array
$data␣=␣"SELECT␣betriebe.name,␣vote.id,␣vote.total,␣vote.votes,␣vote.betriebeid␣FROM␣betriebe,␣vote␣where␣betriebe.id=vote.betriebeid";
$result␣=␣pg_query($conn,␣$data);
//Now␣we␣loop␣through␣all␣the␣data
while($ratings␣=␣pg_fetch_array(␣$result))
{
//This␣outputs␣the␣sites␣name
echo␣"Name:␣"␣.$ratings['name']."<br>";
//This␣calculates␣the␣sites␣ranking␣and␣then␣outputs␣it␣-␣rounded␣to␣1␣decimal
$current␣=␣$ratings[total]␣/␣$ratings[votes];
echo␣"Current␣Rating:␣"␣.␣round($current,␣1)␣.␣"<br>";
//This␣creates␣5␣links␣to␣vote␣a␣1,␣2,␣3,␣4,␣or␣5␣rating␣for␣each␣particular␣item
echo␣"Rank␣Me:␣";
echo␣"<a␣href=".$_SERVER['PHP_SELF']."?mode=vote&voted=1&id=".$ratings[id].">Vote␣1</a>␣|␣";
echo␣"<a␣href=".$_SERVER['PHP_SELF']."?mode=vote&voted=2&id=".$ratings[id].">Vote␣2</a>␣|␣";
echo␣"<a␣href=".$_SERVER['PHP_SELF']."?mode=vote&voted=3&id=".$ratings[id].">Vote␣3</a>␣|␣";
echo␣"<a␣href=".$_SERVER['PHP_SELF']."?mode=vote&voted=4&id=".$ratings[id].">Vote␣4</a>␣|␣";
echo␣"<a␣href=".$_SERVER['PHP_SELF']."?mode=vote&voted=5&id=".$ratings[id].">Vote␣5</a><p>";
}
pg_close($conn);
?>