1 / 18

第四組 停車場搜尋系統

第四組 停車場搜尋系統. 第四組 溫允中 陳欣暉 蕭積遠 李雅俐. 本週進度 20111019. phpsqlajax_dbinfo.php. 放置資料庫連線資訊 - 無法另外做存取 <? php $username=“[user]"; $password=“[password]"; $database=“ [database name]"; ?>. phpsqlajax_genxml3.php. <? php require("phpsqlajax_dbinfo.php"); . . . . .

gerek
Download Presentation

第四組 停車場搜尋系統

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第四組 停車場搜尋系統 第四組 溫允中 陳欣暉 蕭積遠 李雅俐

  2. 本週進度 20111019

  3. phpsqlajax_dbinfo.php 放置資料庫連線資訊-無法另外做存取 <?php $username=“[user]"; $password=“[password]"; $database=“ [database name]"; ?>

  4. phpsqlajax_genxml3.php <?php require("phpsqlajax_dbinfo.php"); . . . . . // Select all the rows in the markers table mysql_query('SET NAMES UTF8'); $query = "SELECT * FROM markers WHERE 1";$result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } header("Content-type: text/xml"); // Start XML file, echo parent node echo '<markers>'; // Iterate through the rows, printing XML nodes for each while ($row = @mysql_fetch_assoc($result)){ // ADD TO XML DOCUMENT NODE echo '<marker '; echo 'name="' . parseToXML($row['name']) . '" '; echo 'address="' . parseToXML($row['address']) . '" '; echo 'lat="' . $row['lat'] . '" '; echo 'lng="' . $row['lng'] . '" '; echo 'type="' . $row['type'] . '" '; echo '/>'; } // End XML file echo '</markers>'; ?>

  5. phpsqlajax_genxml3.php 產生資料表內容

  6. Test02.php variconBlue = new GIcon(); iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png'; iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'; iconBlue.iconSize = new GSize(12, 20); iconBlue.shadowSize = new GSize(22, 20); iconBlue.iconAnchor = new GPoint(6, 20); iconBlue.infoWindowAnchor = new GPoint(5, 1); variconRed = new GIcon(); iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png'; iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'; iconRed.iconSize = new GSize(12, 20); iconRed.shadowSize = new GSize(22, 20); iconRed.iconAnchor = new GPoint(6, 20); iconRed.infoWindowAnchor = new GPoint(5, 1);

  7. varcustomIcons = []; customIcons["restaurant"] = iconBlue; customIcons["bar"] = iconRed; //�a�ϸ�T function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(22.99925, 120.25288), 15); //�����Ʈw GDownloadUrl("phpsqlajax_genxml3.php", function(data) { var xml = GXml.parse(data); var markers = xml.documentElement.getElementsByTagName("marker"); for (vari = 0; i < markers.length; i++) { var name = markers[i].getAttribute("name"); var address = markers[i].getAttribute("address"); var type = markers[i].getAttribute("type"); var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); var marker = createMarker(point, name, address, type); map.addOverlay(marker);

  8. function createMarker(point, name, address, type) { var marker = new GMarker(point, customIcons[type]); var html = "<b>" + name + "</b> <br/>" + address; GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); }); return marker;

  9. 新增搜尋功能

  10. 之前進度 20110928

  11. mysql web介面

  12. 設定資料欄位類型

  13. 建立一個名為wholocations的資料表 CREATE TABLE wholocations ( id int(11) NOT NULL auto_increment, lat decimal(10,6) NOT NULL default '0.000000', lon decimal(10,6) NOT NULL default '0.000000', description varchar(255) NOT NULL default '', PRIMARY KEY (id) ) TYPE=MyISAM;

  14. 輸入你的api key <html><head><title>Who locations in London</title><script src="http://maps.google.com/maps?file=api&v=2&key=[your Google Maps key]" type="text/javascript"></script></head><body><p><strong>Who-locations in London</strong></p><div id="map" style="width: 800px; height: 600px"></div>

  15. 讀取資料庫的資料和多個圖釘點的建立 • <script type="text/javascript">//<![CDATA[var map = new GMap2(document.getElementById("map"));map.addControl(new GLargeMapControl());map.addControl(new GMapTypeControl());map.addControl(new GScaleControl());map.setCenter(new GLatLng(51.512161, -0.14110), 11, G_NORMAL_MAP);// Creates a marker whose info window displays the given numberfunction createMarker(point, number){var marker = new GMarker(point);// Show this markers index in the info window when it is clickedvar html = number;GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});return marker;};

  16. 透過echo的方式把圖釘點一個個產生出來 • <?php$link = mysql_connect("[database server]", "[username]", "[password]") or die("Could not connect: " . mysql_error());mysql_selectdb("[database name]",$link) or die ("Can\'t use dbmapserver : " . mysql_error());$result = mysql_query("SELECT * FROM wholocations",$link);if (!$result){echo "no results “;}while($row = mysql_fetch_array($result)){echo "var point = new GLatLng(" . $row['lat'] . "," . $row['lon'] . ");\n";echo "var marker = createMarker(point, '" . addslashes($row['description']) . "');\n";echo "map.addOverlay(marker);\n";echo "\n";}mysql_close($link);?>//]]></script></body></html>

More Related