Jump to content

Google Maps


hellouthere

Recommended Posts

I hav in the past written a script for oogle maps, this script takes some info from a database, writes it to an xml file then tthe google script takes the info and puts in on the map,  have one version of this running perfectly well...

 

I am now trying to use slightly differrent info... i can get the data as far as the xml file but when i try to show it on the google map it just shows a plain map...

 

this is the script for taking the info from the xml to the map...

 

<?php
include("mark.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>

<HEAD>
<title>FlybeVirtual - Google Map</title>





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

</head>



  <body>
  <table width="100%" style="padding:5px" bgcolor="#DCDDDE">
  	<tr>
	<td bgcolor="#EFEFEF">
	<b><font size="3">Users Online - </font>
	</b>

	<font size="3">
	<span style="font-weight: 700"><?php echo $numonline;?></span></font>
	</td>
</tr>
  	<tr>
	<td>
    <div id="map" style="width: 100%; height: 400px"></div>
	</td>
</tr>
  </table>

    <script type="text/javascript">
    //<![CDATA[
    
    var map = new GMap(document.getElementById("map"));
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
map.setMapType(G_SATELLITE_TYPE);
    map.centerAndZoom(new GPoint(-5.3173828125, 53.74871079689897), 13);


var red = new GIcon();
red.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
red.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
red.iconSize = new GSize(12, 20);
red.shadowSize = new GSize(22, 20);
red.iconAnchor = new GPoint(6, 20);
red.infoWindowAnchor = new GPoint(5, 1);

var yellow = new GIcon();
yellow.image = "http://labs.google.com/ridefinder/images/mm_20_yellow.png";
yellow.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
yellow.iconSize = new GSize(12, 20);
yellow.shadowSize = new GSize(22, 20);
yellow.iconAnchor = new GPoint(6, 20);
yellow.infoWindowAnchor = new GPoint(5, 1);

var green = new GIcon();
green.image = "http://labs.google.com/ridefinder/images/mm_20_green.png";
green.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
green.iconSize = new GSize(12, 20);
green.shadowSize = new GSize(22, 20);
green.iconAnchor = new GPoint(6, 20);
green.infoWindowAnchor = new GPoint(5, 1);

var blue = new GIcon();
blue.image = "http://labs.google.com/ridefinder/images/mm_20_blue.png";
blue.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
blue.iconSize = new GSize(12, 20);
blue.shadowSize = new GSize(22, 20);
blue.iconAnchor = new GPoint(6, 20);
blue.infoWindowAnchor = new GPoint(5, 1);

var orange = new GIcon();
orange.image = "http://labs.google.com/ridefinder/images/mm_20_orange.png";
orange.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
orange.iconSize = new GSize(12, 20);
orange.shadowSize = new GSize(22, 20);
orange.iconAnchor = new GPoint(6, 20);
orange.infoWindowAnchor = new GPoint(5, 1);

var purple = new GIcon();
purple.image = "http://labs.google.com/ridefinder/images/mm_20_purple.png";
purple.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
purple.iconSize = new GSize(12, 20);
purple.shadowSize = new GSize(22, 20);
purple.iconAnchor = new GPoint(6, 20);
purple.infoWindowAnchor = new GPoint(5, 1);

var gray = new GIcon();
gray.image = "http://labs.google.com/ridefinder/images/mm_20_gray.png";
gray.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
gray.iconSize = new GSize(12, 20);
gray.shadowSize = new GSize(22, 20);
gray.iconAnchor = new GPoint(6, 20);
gray.infoWindowAnchor = new GPoint(5, 1);

var brown = new GIcon();
brown.image = "http://labs.google.com/ridefinder/images/mm_20_brown.png";
brown.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
brown.iconSize = new GSize(12, 20);
brown.shadowSize = new GSize(22, 20);
brown.iconAnchor = new GPoint(6, 20);
brown.infoWindowAnchor = new GPoint(5, 1);

var white = new GIcon();
white.image = "http://labs.google.com/ridefinder/images/mm_20_white.png";
white.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
white.iconSize = new GSize(12, 20);
white.shadowSize = new GSize(22, 20);
white.iconAnchor = new GPoint(6, 20);
white.infoWindowAnchor = new GPoint(5, 1);

var black = new GIcon();
black.image = "http://labs.google.com/ridefinder/images/mm_20_black.png";
black.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
black.iconSize = new GSize(12, 20);
black.shadowSize = new GSize(22, 20);
black.iconAnchor = new GPoint(6, 20);
black.infoWindowAnchor = new GPoint(5, 1);

function icon(color) {

if(color == "green")
{
        var icon = green
}
else if(color == "red")
{
        var icon = red
}
else if(color == "yellow")
{
        var icon = yellow
}
else if(color == "black")
{
        var icon = black
}
else if(color == "blue")
{
        var icon = blue
}
else if(color == "orange")
{
        var icon = orange
}
else if(color == "purple")
{
        var icon = purple
}
else if(color == "gray")
{
        var icon = gray
}
else if(color == "brown")
{
        var icon = brown
}
else if(color == "white")
{
        var icon = white
}
return icon
}

function createMarker(point, status, color, last, callsign, name, flightno, depICAO, destICAO, depname, destname, gs, alt) {
  var marker = new GMarker(point, icon(color));

var infoTabs = [
  new GInfoWindowTab("Pilot Info", "<table><tr><td STYLE='line-height: 1.5; font-size: 11pt; font-family: vardana'><div align=\"left\"><b>"+ name + "</b> ("+ callsign +")</div><hr></td></tr></table><table><tr><td STYLE='line-height: 1.3; font-size: 10pt; font-family: vardana'><div align=\"left\">Ground Speed: "+ gs + "</div><div align=\"left\">Altitude: "+ alt + "</div><div align=\"left\">IVAO ID: "+  + "</div></td></tr></table>"),
  new GInfoWindowTab("Flight Data", "<table><tr><td STYLE='line-height: 1.3; font-size: 10pt; font-family: vardana'><div align=\"left\">Flight: "+ flightno + "</div><div align=\"left\">Status: "+ status + "</div><div align=\"left\">From: "+ depICAO +" - "+ depname +"</div><div align=\"left\">To: "+ depICAO +" - "+ depname +"</div><div align=\"left\">Last Mesage: "+ lstmsg + "</div></td></tr></table>")
];


  GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowTabsHtml(infoTabs);

  });
  return marker;
}

var request = GXmlHttp.create();
request.open('GET', 'mark.xml', true);
request.onreadystatechange = function() {
  if (request.readyState == 4) {
        var xmlDoc = request.responseXML;
        var markers = xmlDoc.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {
        var status = markers[i].getAttribute("status")
        var color = markers[i].getAttribute("color")
        var last = markers[i].getAttribute("last")
        var callsign = markers[i].getAttribute("callsign")
        var name = markers[i].getAttribute("name")
        var flightno = markers[i].getAttribute("flightno")
	var depICAO = markers[i].getAttribute("depICAO")
	var destICAO = markers[i].getAttribute("destICAO")
	var depname = markers[i].getAttribute("depname")
	var destname = markers[i].getAttribute("destname")
	var gs = markers[i].getAttribute("gs")
	var alt = markers[i].getAttribute("alt")
        var point = new GPoint(parseFloat(markers[i].getAttribute("lon")),parseFloat(markers[i].getAttribute("lat")));
        var marker = createMarker(point, status, color, last, callsign, name, flightno, depICAO, destICAO, depname, destname, gs, alt);
          map.addOverlay(marker);
        }
  }
}

var locvar = map.getCenterLatLng();
var zoomvar = map.getZoomLevel();
GEvent.addListener(map, 'move', function() {
locvar = map.getCenterLatLng();
zoomvar = map.getZoomLevel();
});

GEvent.addListener(map, 'zoom', function() {
locvar = map.getCenterLatLng();
zoomvar = map.getZoomLevel();
});

request.send(null);
    //]]>
   </script>



</BODY>

</HTML>

 

Im not amazingly experienced with javascript, i managed to get it running before but cannot for the life of me find any errors, if you need me to explain parts of the script tthen let me know...

 

Thanks in advance...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.