damit nichts durcheinander kommt, habe ich den alten Text mal gelöscht.
Nun geht es, man kann Daten aus der simple_user auslesen und als Googlemap darstellen.
Demo hier:
http://www.mediaborken.de/index.php?article_id=47
War richtig stress, für jemanden der normalerweise nur mit Grafik rumdoktert. Nun gut, lange Rede kurzer Sinn. Man benötigt eine Datei Namens read.php im files Verzeichnis von Redaxo:
In dem zu verwendenden Template noch ein:
<body onunload="GUnload()"> einfügen.
Man kann bestimmt alles noch eleganter (schlanker) loesen, aber ich bin erst einmal froh dieses überhaupt hinbekommen zu haben
read.php
Code: Alles auswählen
<?
// Nur User ausgeben, die den Status auf online haben = user_skype = "on" (Feld user_skype dafuer verwendet)
$host = 'dein Host';
$user = 'dein Datenbank Username';
$pass = 'dein datenbank Passwort';
$dbname = 'der Datenbankname';
if (!$db = mysql_connect($host, $user, $pass)) {
echo 'Could not connect to mysql';
exit;
}
if (!mysql_select_db($dbname, $db)) {
echo 'Could not select database';
exit;
}
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
//XML Header
header("content-type:text/xml");
$query = "SELECT * FROM rex_2_user WHERE user_skype = 'on' ORDER BY company_name ASC";
$query = mysql_query($query);
echo "<markers>";
while ($row=mysql_fetch_assoc($query)){
echo '<marker html="'.$row['personally_positive_characteristics'].'" lng="'.$row['user_file2'].'" lat="'.$row['user_file1'].'" label="'.$row['company_name'].'"></marker>';
}
echo "</markers>";
?>
Code: Alles auswählen
Google API Key:
<br />
<input type="text" size="50" name="VALUE[1]" value="REX_VALUE[1]" />
<br />
Zoom-Faktor:
<br />
<select name="VALUE[2]" >
<?php
foreach (array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15) as $value) {
echo '<option value="'.$value.'" ';
if ( "REX_VALUE[2]"=="$value" ) {
echo 'selected="selected" ';
}
echo '>'.$value.'</option>';
}
?>
</select><br /><br />
Karte zentrieren auf welche Koordinaten?
<br />
Lat:<br />
<input type="text" size="30" name="VALUE[3]" value="REX_VALUE[3]" />
<br />
Lon:<br />
<input type="text" size="30" name="VALUE[4]" value="REX_VALUE[4]" />
<br />
Code: Alles auswählen
<script src='http://maps.google.de/maps?file=api&v=2&key=REX_VALUE[1]' type='text/javascript'></script>
<!-- you can use tables or divs for the overall layout -->
<table border=1>
<tr>
<td>
<div id="map" style="width: 550px; height: 450px"></div>
</td>
<td width = 150 valign="top" style="text-decoration: underline; color: #4444ff;">
<div id="sidebar"></div>
</td>
</tr>
</table>
<noscript><b>JavaScript must be enabled in order for you to use Google Maps.</b>
However, it seems JavaScript is either disabled or not supported by your browser.
To view Google Maps, enable JavaScript by changing your browser options, and then
try again.
</noscript>
<script type="text/javascript">
//<![CDATA[
if (GBrowserIsCompatible()) {
// this variable will collect the html which will eventualkly be placed in the sidebar
var sidebar_html = "";
// arrays to hold copies of the markers and html used by the sidebar
// because the function closure trick doesnt work there
var gmarkers = [];
var htmls = [];
var i = 0;
// A function to create the marker and set up the event window
function createMarker(point,name,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
// save the info we need to use later for the sidebar
gmarkers[i] = marker;
htmls[i] = html;
// add a line to the sidebar html
sidebar_html += '<a href="javascript:myclick(' + i + ')">' + name + '</a><br>';
i++;
return marker;
}
// This function picks up the click and opens the corresponding info window
function myclick(i) {
gmarkers[i].openInfoWindowHtml(htmls[i]);
}
// create the map
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(REX_VALUE[3],REX_VALUE[4]), REX_VALUE[2]);
var urlstr="files/read.php";
var request = GXmlHttp.create();
request.open("GET", urlstr, true);
// Read the data from example.xml
// var request = GXmlHttp.create();
// request.open("GET", "example.xml", true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
var xmlDoc = request.responseXML;
// obtain the array of markers and loop through it
var markers = xmlDoc.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
// obtain the attribues of each marker
var lat = parseFloat(markers[i].getAttribute("lat"));
var lng = parseFloat(markers[i].getAttribute("lng"));
var point = new GLatLng(lat,lng);
var html = markers[i].getAttribute("html");
var label = markers[i].getAttribute("label");
// create the marker
var marker = createMarker(point,label,html);
map.addOverlay(marker);
}
// put the assembled sidebar_html contents into the sidebar div
document.getElementById("sidebar").innerHTML = sidebar_html;
}
}
request.send(null);
}
else {
alert("Sorry, the Google Maps API is not compatible with this browser");
}
// This Javascript is based on code provided by the
// Blackpool Community Church Javascript Team
// http://www.commchurch.freeserve.co.uk/
// http://www.econym.demon.co.uk/googlemaps/
//]]>
</script>
Edit: habe auch heraus gefunden wie man weitere Felder (Telefon etc.) darstellen kann, siehe Link oben.
Wenn ich es mal alles ein wenig eleganter gelöst habe, stelle ich es bei den Modulen ein.