Apache & ArcMap Geodatabase Zip File Contents

(all asp & php scripts use the same arcmap geodatabase)
asp ado dsn less & php odbc connection examples




Google Map API .asp Example - More Script Examples

Explanation of State PHP Script for MS_Access DataBase

The php scripts are  not in any means formal   ,they will give a  introduction to connecting to a db and displaying attributes in kml format. For in-depth comprehension Read: Using PHP and MySQL to create KML - Tutorial by Mano Marks 

Breakdown of PHP used with MS_Access Geodatabase & Apache for Google Earth
 

doc.kml
 

whats happening in PHP Script odbc_states.php3
click to view xml output
or create NetLink in GEarth, Link =
http://jpwade.mooo.com/test/odbc_states.php3
     
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<Document>
<StyleMap id="dot">
</StyleMap>
<Style id="dot">
<IconStyle>
<scale>0.7</scale>
<Icon><href>http://maps.../icon46.png</href>
</Icon>
</IconStyle>
<LabelStyle><color>ff7fffff</color>
<scale>0.8</scale>
</LabelStyle></Style>
<Folder>
<name>Locations</name>
<open>1</open>
Echo header, Style Tags, etc of Kml  up to  Placemark Tag <?php
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<kml xmlns="http://earth.google.com/kml/2.0">';
echo '<Document>';
echo '<StyleMap id="dot">';
echo '</StyleMap>';
echo '<Style id="dot">';
echo '<IconStyle>';
echo '<scale>0.7</scale>';
echo '<Icon>';
echo '<href>http://maps.../icon46.png</href>';
echo '</Icon>';
echo '</IconStyle>';
echo '<LabelStyle>';
echo '<color>ff7fffff</color>';
echo '<scale>0.8</scale>';
echo '</LabelStyle>';
echo '</Style>';
echo '<Folder>';
echo '<name>Locations</name>';
echo '<open>1</open>';
     
 

 

$cnx = Connect to db, with system  dsn named "arcmap"

no passwrd/ usrname

$sql = Query Table  States

$cnx = odbc_connect('arcmap', 'root','') or exit("Could not connect to ODBC database!");
 

$sql = "SELECT * FROM STATES"; // (*) says select ALL fields
 

$result = odbc_exec($cnx, $sql) or exit(odbc_errormsg());

     
  Start Loop through database and create placemark for each record based on Fields 1 - 12 in db Table

(table = states in this example)

while(odbc_fetch_row($result))

{
$objectid = odbc_result($result, 1);
$shape = odbc_result($result, 2);
$pop1990 = odbc_result($result, 3);
$households = odbc_result($result, 4);
$male = odbc_result($result, 5);
$female = odbc_result($result, 6);
$x = odbc_result($result, 7);
$y = odbc_result($result, 8);
$name = odbc_result($result, 9);
$alt_10 = odbc_result($result, 10);
$t_in = odbc_result($result, 11);
$t_out = odbc_result($result, 12);
Placemark Open to  Close - Blue Text is what changes for each placemark created during the loop in the php script  
Blue text is the Field/Column  of each record
<Placemark>
<description><![CDATA[ Text ]]></description>
<name>Placemark_Name</name>
<TimeSpan>
<begin>0</begin>
<end>1</end>
</TimeSpan>
<visibility>1</visibility>
<styleUrl>#dot</styleUrl>
<Point>
<extrude>1</extrude>
<altitudeMode>relativeToGround</altitudeMode>
<coordinates>-120.42802745,47.376761953,486669</coordinates>
</Point>
</Placemark>
Create placemarks from each record in db

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

End Loop

$response = '<Placemark>';
$response .= '<description><![CDATA[';
$response .= 'Name: ';
$response .= $name;
$response .= '<br>';
$response .= 'Objectid: ';
$response .= $objectid;
$response .= '<br>';
$response .= 'Pop1990: ';
$response .= $pop1990;
$response .= '<br>';
$response .= 'Households: ';
$response .= $households;
$response .= '<br>';
$response .= 'Males: ';
$response .= $male;
$response .= '<br>';
$response .= 'Females: ';
$response .= $female;
$response .= '<br>';
$response .= ']]></description>';
$response .= '<name>';
$response .= $name;
$response .= '</name>';
$response .= '<TimeSpan><begin>';
$response .= $t_in;
$response .= '</begin><end>';
$response .= $t_out;
$response .= '</end></TimeSpan>';
$response .= '<visibility>1</visibility>';
$response .= '<styleUrl>#dot</styleUrl>';
$response .= '<Point>';
$response .= '<extrude>1</extrude>';
$response .= '<altitudeMode>relativeToGround</altitudeMode>';
$response .= '<coordinates>';
$response .= $x;
$response .= ',';
$response .= $y;
$response .= ',';
$response .= $alt_10;
$response .= '</coordinates>';
$response .= '</Point>';
$response .= '</Placemark>';
echo $response;
}
     
</Folder>
</Document>
</kml>
echo footer and close connection echo "</Folder>";
echo "</Document>";
echo "</kml>";

odbc_close($cnx)
?>
     
     

 

 

 

 

 

Setup Template to Create Scripts for GEarth and GMaps

1) In Google Earth, Create a Folder and create a Placemark inside of it , customize the icon and save it to your hard drive,

2) GE saves the file with a .kmz extension,  rename the filename.kmz to filename.zip and unzip it.

3) you will end up with a file named doc.kml, open the file with wordpad and review its structure
      to create animation time tags insert  <TimeSpan><begin>0</begin><end>1</end></TimeSpan> after </name> under the <placemark> varibles and save the doc.kml

4) utilized the above table to make a odbc_php script.

5) the state and city attributes in the ArcMap geodatabase have the same column (field) names, so the Table Name in the Query statement of odbc_cities.php & odbc_states.php is all that needs to be changed.

 


An introduction to setting up a Apache WebServer, using phpMyAdmin, connecting to a MS_Access or MySql database
  to display attributes in GEarth and Gmaps, GEarth API,  etc

SetUp a Home WebServer

Using PHP and MySQL to Create KML

Set your Apache Server for ArcMap Geodatabase

Zip File Contents and  Explination of Scripts (includes GEarth API)

Create MySQL DB from Exported Data of the ArcMap GeoDatabase

Add Polygons From ArcMap to MySQL DB

Put Your Server On-Line, Tool Tips, Other

Index Page    |    Home Page