IIS - Windows Server Example - GE-API


webpage.asp
: connects to MS access database "arcmap.mdb" / table = STATES:


 

<html>

<head>

<title>ASP Maps API</title>


<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2.x&key=................"></script>

<script type="text/javascript">
function initialize() {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(47.4328, -94.077), 3);

// The following line makes the map Earth-enabled by adding the
// "Earth" button to the map type control. Note that you still
// need to add a map type control (GMapTypeControl,
// GMenuMapTypeControl, or GHierarchicalMapTypeControl) to the
// the map (as is done below) for the "Earth" button and the rest
// of the map type buttons to show up at all.
// Also, be sure you are loading v=2.x of the Maps API and not
// v=2, otherwise the G_SATELLITE_3D_MAP map type will not
// work properly.
map.addMapType(G_SATELLITE_3D_MAP);

map.addControl(new GHierarchicalMapTypeControl());
map.addControl(new GLargeMapControl());


var baseIcon = new GIcon();
baseIcon.iconSize=new GSize(32,32);
baseIcon.shadowSize=new GSize(56,32);
baseIcon.iconAnchor=new GPoint(16,32);
baseIcon.infoWindowAnchor=new GPoint(16,0);

var red = new GIcon(baseIcon, "http://maps.google.com/mapfiles/ms/micons/red-dot.png");
var yellow = new GIcon(baseIcon, "http://maps.google.com/mapfiles/ms/micons/yellow-dot.png");
var green = new GIcon(baseIcon, "http://maps.google.com/mapfiles/ms/micons/green-dot.png");



function createMarker(point,html,icon) {
var marker = new GMarker(point,icon);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}

// Set up markers with info windows



<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsRecords 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database



'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("arcmap.mdb")

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=arcmap"

'Create an ADO recordset object
Set rsRecords = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT STATES.OBJECTID, STATES.Shape, STATES.POP1990, STATES.HOUSEHOLDS, STATES.MALES, STATES.FEMALES, STATES.x, STATES.y, STATES.NAME, STATES.alt_10, STATES.t_in, STATES.t_out, STATES.ICON FROM STATES;"


'Open the recordset with the SQL query
rsRecords.Open strSQL, adoCon

'Loop through the recordset
Do While not rsRecords.EOF

'Write the HTML to display the current record in the recordset


// Lat Lon

Response.Write ("var point = new GLatLng(")
Response.Write (rsRecords("y"))
Response.Write (",")
Response.Write (rsRecords("x"))
Response.Write (");")

// marker and infowindow
// retrieves from db column the attributes

Response.Write ("var marker = createMarker(point,")
Response.Write ("'")
Response.Write ("<div style=width:240px>")

Response.Write (rsRecords("NAME"))
Response.Write ("<br>")

Response.Write ("<br>")
Response.Write ("Population 1990: ")
Response.Write (rsRecords("POP1990"))
Response.Write ("<br>")

Response.Write (" > 4900000 = Red")
Response.Write ("<br>")
Response.Write (" > 1200000 = Yellow")
Response.Write ("<br><br>")

Response.Write ("Households: ")
Response.Write (rsRecords("HOUSEHOLDS"))
Response.Write ("<br>")
Response.Write ("Males: ")
Response.Write (rsRecords("MALES"))
Response.Write ("<br>")
Response.Write ("Females: ")
Response.Write (rsRecords("FEMALES"))
Response.Write ("<br>")







Response.Write ("</div>")
Response.Write ("'")
Response.Write (",")

// Set marker type
// retrieves from db column ICON

Response.Write (rsRecords("ICON"))
Response.Write (");")



Response.Write ("map.addOverlay(marker);")





'Move to the next record in the recordset
rsRecords.MoveNext

Loop

'Reset server objects
rsRecords.Close
Set rsRecords = Nothing
Set adoCon = Nothing
%>


}
</script>

</head>
<body onload="initialize()" onunlaod="GUnload">
<div id="map" class="map" style="width:450px;height:350px"></div>
</body>

</html>

 


 

 

 

IIS - Windows Server Example - GE-API with .dae


webpage.asp
: connects to MS access database "arcmap.mdb" / table = STATES:



<html>
<head>
<title></title>


<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2.x&key=........"></script>

<script type="text/javascript">

function initialize() {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(47.4328, -94.077), 3);

map.addMapType(G_SATELLITE_3D_MAP);

map.addControl(new GHierarchicalMapTypeControl());
map.addControl(new GSmallMapControl());


var baseIcon = new GIcon();
baseIcon.iconSize=new GSize(32,32);
baseIcon.shadowSize=new GSize(56,32);
baseIcon.iconAnchor=new GPoint(16,32);
baseIcon.infoWindowAnchor=new GPoint(16,0);

var red = new GIcon(baseIcon, "http://maps.google.com/mapfiles/ms/micons/red-dot.png");
var yellow = new GIcon(baseIcon, "http://maps.google.com/mapfiles/ms/micons/yellow-dot.png");
var green = new GIcon(baseIcon, "http://maps.google.com/mapfiles/ms/micons/green-dot.png");



function createMarker(point,html,icon) {
var marker = new GMarker(point,icon);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}


map.getEarthInstance(getEarthInstanceCB);


// Set up markers with info windows



<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsRecords 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database



'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("arcmap.mdb")

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=arcmap"

'Create an ADO recordset object
Set rsRecords = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT STATES.OBJECTID, STATES.Shape, STATES.POP1990, STATES.HOUSEHOLDS, STATES.MALES, STATES.FEMALES, STATES.x, STATES.y, STATES.NAME, STATES.alt_10, STATES.t_in, STATES.t_out, STATES.ICON FROM STATES;"


'Open the recordset with the SQL query
rsRecords.Open strSQL, adoCon

'Loop through the recordset
Do While not rsRecords.EOF

'Write the HTML to display the current record in the recordset


// Lat Lon

Response.Write ("var point = new GLatLng(")
Response.Write (rsRecords("y"))
Response.Write (",")
Response.Write (rsRecords("x"))
Response.Write (");")

// marker and infowindow
// retrieves from db column the attributes

Response.Write ("var marker = createMarker(point,")
Response.Write ("'")
Response.Write ("<div style=width:240px>")

Response.Write (rsRecords("NAME"))
Response.Write ("<br>")

Response.Write ("<br>")
Response.Write ("Population 1990: ")
Response.Write (rsRecords("POP1990"))
Response.Write ("<br>")

Response.Write (" > 4900000 = Red")
Response.Write ("<br>")
Response.Write (" > 1200000 = Yellow")
Response.Write ("<br><br>")

Response.Write ("Households: ")
Response.Write (rsRecords("HOUSEHOLDS"))
Response.Write ("<br>")
Response.Write ("Males: ")
Response.Write (rsRecords("MALES"))
Response.Write ("<br>")
Response.Write ("Females: ")
Response.Write (rsRecords("FEMALES"))
Response.Write ("<br>")

Response.Write ("</div>")
Response.Write ("'")
Response.Write (",")

// Set marker type
// retrieves from db column ICON

Response.Write (rsRecords("ICON"))
Response.Write (");")
Response.Write ("map.addOverlay(marker);")


'Move to the next record in the recordset
rsRecords.MoveNext

Loop

'Reset server objects
rsRecords.Close
Set rsRecords = Nothing
Set adoCon = Nothing
%>


}


var ge;
function getEarthInstanceCB(object, lat, long , title)
{
ge = object;
get_3d();
}



function get_3d()
{
var networkLink = ge.createNetworkLink("");
networkLink.setDescription("Open content description");
networkLink.setName("Open NetLink");

var link = ge.createLink("");

link.setHref("http://www.czmartin.com/jpw/asp_arcmap/arcmap_geodatabase.kmz");

networkLink.setLink(link);
ge.getFeatures().appendChild(networkLink);

}



</script>


</head>
<body onload="initialize()" onunlaod="GUnload">
<div id="map" class="map" style="width:450px;height:350px"></div>

</body>
</html>