ผู้เขียน หัวข้อ: มีใครเก่ง google map บ้างครับ  (อ่าน 5935 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

ออฟไลน์ Apiruk_Jbhos

  • Sr. Member
  • ****
  • กระทู้: 386
  • Respect: +1
    • ดูรายละเอียด
    • โรงพยาบาล สมเด็จพระยุพราช จอมบึง
มีใครเก่ง google map บ้างครับ
« เมื่อ: กรกฎาคม 21, 2008, 10:47:53 AM »
0
สวัสดีครับ ตอนนี้อยากทำ google map เอาไว้เก็บข้อมูล คนไข้ และ บ้านพักเจ้าหน้าที่ และสถาที่สำคัญ
แต่ติดตรง code ที่ต้องการเข้าไปดุใน google code ก้ยัง งง เลยอยากถามว่ามีใครพอจะช่วยได้บ้าง
สำหรับตอนนี้ที่ทำได้แล้ว ก้สามารถ เก็บ พิกัด ประเภท แล้ว mark จุดลงแผนที่ได้แล้ว ที่ติดก้อยากจะทำ link ที่ชื่อ แล้วให้มัน วิ่งไปหาพิกัดที่เราเลือก และแบ่ง ประเภทให้ เพราะตอนนี้ มัน รวมกันอยู่ พอมีใครเล่นบ้างครับ
นาย อภิรักษ์ ชุ่มชะอุ่ม
Mail advance_pro@hotmail.com
โรงพยาบาล สมเด็จพระยุพราช จอมบึง

Server 1 : SR550 Ram 64G
OS1 : CentOS Linux 7.6
MariaDB version 10.1.19

Server 2 : IBM X3500 Ram 6G
OS2 : CentOS 7.6


ขึ้นระบบ เดือน กรกฎาคม 50
http://www.ChomBungHospital.com/

ออฟไลน์ jdadmin1

  • Hero Member
  • *****
  • กระทู้: 6,468
  • "เครื่องชำรุด...งดใช้งานชั่วคราว"
  • Respect: +33
    • ดูรายละเอียด
Re: มีใครเก่ง google map บ้างครับ
« ตอบกลับ #1 เมื่อ: กรกฎาคม 21, 2008, 11:29:44 AM »
0
 ??? ??? ??? งง งง ครับ ท่าน Apirak ช่วยถามใหม่อีกสักครั้งครับว่าที่ต้องการคือยังไง  ;D ;D ;D
โรงพยาบาลพระสมุทรเจดีย์สวาทยานนท์ จังหวัดสมุทรปราการ
Master   : HOSxP 3.67.6.5
Slave1   : HOSxP 3.67.6.5
Upgrade 8/06/2567
Facebook : Suntad Mamak

ออฟไลน์ Apiruk_Jbhos

  • Sr. Member
  • ****
  • กระทู้: 386
  • Respect: +1
    • ดูรายละเอียด
    • โรงพยาบาล สมเด็จพระยุพราช จอมบึง
Re: มีใครเก่ง google map บ้างครับ
« ตอบกลับ #2 เมื่อ: กรกฎาคม 21, 2008, 11:36:07 AM »
0
 :) ผมใช้ php+mysql อยากได้ code เขี่ยนที่ คลิกที่ชื่อที่เก็บในฐาน แล้วให้มัน วิ่งไปหา พิกัด ในแผนที่ ครับ
และ code แบ่งกลุ่ม
ตย.ที่เขียนอยู่ครับ

$CONFIG{'hostname'} = '127.0.0.1';
$CONFIG{'user'} = 'root';
$CONFIG{'password'} = '367270';
$CONFIG{'db'} = 'test';


# WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING
#
# This script will attempt to create the database specified in $CONFIG{'db'}
# and a table called 'geo' in that database.
#
# WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING




$DBH = DB_Connect();

// Make sure the table exists
assertTable();

// define vars
$desc = '';
$lat = '';
$lon = '';
$type = '';

// read POST variables if present
foreach ($_POST as $name => $value) {
   $$name = $value;
}


// If post variables desc,lat and long are not empty then we're inserting
if ($desc &&  $lat &&  $lon) {
   if (is_numeric($lat) && is_numeric($lon) && is_string($desc)&& is_string($type)) {

      if ($lat < -85 || $lat > 85 || $lon < -180 || $lon > 180) {
         print "You've entered invalid values";
         exit;
      }

      $desc = addslashes(substr($desc,0,200));
      $type = addslashes(substr($type,0,200));
      $sql = "insert into geoPoints values ( null , $lat, $lon, '$desc','$type' )";
      $result = mysql_query($sql,$DBH) or DBError("LINE: " .__LINE__. " $sql");
      print "Point inserted<br><a href=\"{$_SERVER{'PHP_SELF'}}\">Back to the map</a>\n";
      exit;
   }
}


// Get the javascript defining the points after inserting.
$jsPointsArray = getPointsJS();



$pageHTML = <<<EOH

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv=”content-type” content=”text/html; charset=utf-8>
<title>Google Maps JavaScript API - PHP/DB Example</title>

   
<script src="/key.js"></script>
<script>
   var scriptTag = '<' + 'script src="http://maps.google.com/maps?file=api&v=2&key=' + 'ABQIAAAAUZcg0LDyHXOu2Bvuy8lPihT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTtrGuv6Sq4mA3Ym0t1J7DQwJVn9w' + '">'+'<'+'/script>';
   document.write(scriptTag);
</script>



<script type="text/javascript">
var mArray = Array();
var map;
var centerPoint = new GLatLng(13.078071,99.689453);
function load() {
   doLoad();
   $jsPointsArray
   addMarkers();
}

function doLoad() {
   if (GBrowserIsCompatible()) {
      map = new GMap2(document.getElementById("map"));
      map.setCenter(centerPoint, 7);
      map.addControl(new GScaleControl());
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      GEvent.addListener(map, 'click', mapClick);

   }
}

function addMarkers() {
   if (mArray.length) {
      var bounds = new GLatLngBounds();
      for (n=0 ; n < mArray.length ; n++ ) {
         var mData = mArray[n].split(';');
         var point = new GLatLng(mData[0],mData[1]);
         bounds.extend(point);
         var marker = createMarker(point, mData[2]);
         map.addOverlay(marker);
      }
      map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
   }
}

function createMarker(point, title) {
   var marker = new GMarker(point,{title:title});
   GEvent.addListener(marker, "click", function() {
      marker.openInfoWindowHtml('<div style="width:250px;">' + title + '<hr>Lat: ' + point.y + '<br>Lon: ' + point.x + '</div>');
   });
   return marker;
}

function mapClick(marker, point) {
   if (!marker) {
      oLat = document.getElementById("lat");
      oLat.value = point.y;
      oLon = document.getElementById("lon");
      oLon.value = point.x;
      oDesc = document.getElementById("desc");
      oDesc.value = 'New desc';
      otype = document.getElementById("type");
      otype.value = 'New type';


   }
}



</script>
</head>


<body onload="load()" onunload="GUnload()">
<div id="msg" style="width: 680px; border: 1px solid gray;font: bold 12px verdana;padding:3px;margin:10px;">
Note: Markers from all different visitors are going into the same database and are displayed together.<br>
They could be separated, but I chose to keep it simple. I'll empty the databse once in a while.
</div>

<div id="map" style="width: 700px; height: 500px"></div>


<div id="formDiv">
<table cellspacing="0" cellpadding="2">
<form method="POST">
   <tr>
      <td colspan="2" align="center">Add a marker</td>
   </tr>
   <tr>
      <td>Description</td>
      <td><input id="desc" name="desc"> Example: 'My marker</td>
   </tr>
   <tr>
      <td>Latitude</td>
      <td><input id="lat" name="lat"> Example: 40.0</td>
   </tr>
   <tr>
      <td>Longitude</td>
      <td><input id="lon" name="lon"> Example: -101.5</td>
   </tr>
   <tr>
      <td>Type</td>
      <td><SELECT NAME="type"id="type">
      <option>Home</option>
      <option>GAS</option>
      <option>Hotel</option>      
      </SELECT></td>
         </tr>
   <tr>
      <td colspan="2" align="center"><input type="submit" value="Add Point"></td>
   </tr>
   
</form>
</table>
</div>




</body>

</html>



EOH;


print $pageHTML;


print DoQueriy('Table contents',"select * from geoPoints order by id");



///////////////////////////// Functions ///////////////////////////////////////

function getPointsJS() {
   global $DBH;
   $sql = "select * from geoPoints";
   $result = mysql_query($sql,$DBH) or DBError("LINE: " .__LINE__. " $sql");
   $nRows = mysql_num_rows($result);

   $javaScript = '';
   if ($nRows) {
      while ($row = mysql_fetch_assoc($result)) {
         $row{'description'} = addslashes($row{'description'});
         $row{'description'} = str_replace(';',',',$row{'description'});
         $javaScript .= "mArray.push('{$row{'lat'}};{$row{'lon'}};{$row{'description'}}')\n";
      }
      
      print "Selected $nRows rows\n";
   }
   else {
      print "No points found in database\n";
   }
   return $javaScript;
}




function assertTable() {
   global $DBH;
   // Create table, if it does not already exist
   $createTableSQL = <<<EOS
   CREATE TABLE IF NOT EXISTS geoPoints (
     id int(11) NOT NULL auto_increment,
     lat decimal(12,8) NOT NULL,
     lon decimal(12,8) NOT NULL,
     description varchar(255) NOT NULL,
     type varchar(50) NOT NULL,
     PRIMARY KEY (id)
   ) TYPE=MyISAM;
EOS;

   $sql = $createTableSQL;
   $result = mysql_query($sql,$DBH) or DBError("LINE: " .__LINE__. " $sql");
}


function DBError($sql){
   print "Error: \n" . mysql_error() . "\n";
   print "<hr>\n";
   print "$sql\n";
   print "<hr>\n";
   exit;
}



function DB_Connect() {
   global $CONFIG;
   $DBH = mysql_connect($CONFIG{'hostname'}, $CONFIG{'user'}, $CONFIG{'password'}) or DBError("LINE: " .__LINE__. " Connect");;

   $sql = "create database IF NOT EXISTS {$CONFIG{'db'}}";
   $result = mysql_query($sql,$DBH) or DBError("LINE: " .__LINE__. " $sql");
   
   mysql_select_db($CONFIG{'db'}, $DBH) or DBError("LINE: " .__LINE__. " Select DB");;
   return $DBH;
}



function DoQueriy($title,$sql){
   global $DBH;
   $HTML = '';

   $result = mysql_query($sql,$DBH) or DBError($sql);
   $colCount = mysql_num_fields($result);
   $rowCount = mysql_num_rows($result);

   $HTML .= "<table cellspacing=\"0\" cellpadding=\"0\" border>\n";
   $HTML .= "<tr>\n";
   $HTML .= "   <td colspan=\"$colCount\" style=\"padding:3px;font-weight:bold;text-align:center;\">\n";
   $HTML .= "   $title\n";
   $HTML .= "   </td>\n";
   $HTML .= "</tr>\n";

   if ($rowCount) {
      if ($row = mysql_fetch_assoc($result)) {
         $HTML .= "<tr>\n";
         foreach ($row as $name => $value) {
            $HTML .= "   <td style=\"padding:3px;\">\n";
            $HTML .=      $name; // หัวตาราง
            $HTML .= "   </td>\n";
         }      
         $HTML .= "</tr>\n";
      }
      
      mysql_data_seek($result,0);
      
      while ($row = mysql_fetch_assoc($result)) {
         $HTML .= "<tr>\n";
         foreach ($row as $name => $value) {
            $HTML .= "   <td style=\"padding:3px;\">\n";
            $HTML .=      $value; // ข้อมูล
            $HTML .= "   </td>\n";
         }      
         $HTML .= "</tr>\n";
      }
   }
   else {
      $HTML .= "<tr>\n";
      $HTML .= "   <td colspan=\"$colCount\" style=\"padding:3px;font-weight:bold;text-align:center;\">\n";
      $HTML .= "   Empty\n";
      $HTML .= "   </td>\n";
      $HTML .= "</tr>\n";
   }
   
   $HTML .= "</table>\n";
   $HTML .= "<br>\n";
   return $HTML;

}


?>
« แก้ไขครั้งสุดท้าย: กรกฎาคม 21, 2008, 11:39:08 AM โดย Apiruk_Jbhos »
นาย อภิรักษ์ ชุ่มชะอุ่ม
Mail advance_pro@hotmail.com
โรงพยาบาล สมเด็จพระยุพราช จอมบึง

Server 1 : SR550 Ram 64G
OS1 : CentOS Linux 7.6
MariaDB version 10.1.19

Server 2 : IBM X3500 Ram 6G
OS2 : CentOS 7.6


ขึ้นระบบ เดือน กรกฎาคม 50
http://www.ChomBungHospital.com/

doramon

  • บุคคลทั่วไป
Re: มีใครเก่ง google map บ้างครับ
« ตอบกลับ #3 เมื่อ: กรกฎาคม 21, 2008, 11:44:32 AM »
0
http://saiyokhosxp.homelinux.net/map/sample.html



ผมไม่เก่ง นะครับ และก็ไม่ได้เขียนโปรแกรม  google map แต่ชอบมัน ประยุกต์ เอามันมาใช้

แบบเดียวกับ hosxp ครับ แค่เป็นคนที่ชอบศึกษาเท่านั้น
ตอนนี้ยังเป็นนักเรียนอยู่เลย  เอาแบบนักเีรียนคุยกับ นักเรียนแล้วกัน





ก็ยังไม่เข้าใจ


ถ้าจะให้ดูให้ส่งมาทั้งหมดที่  mail ก็ได้ครับ

แบบนี้งง


« แก้ไขครั้งสุดท้าย: กรกฎาคม 21, 2008, 12:02:51 PM โดย doraemon(saiyok) »