KML data not being displayed on map?

rbuckwildrh

New Member
I'm afraid reading through numerous tutorials as well as thoroughly scouring the relevant documentation.I am using Nokia maps on my website, and am dynamically generating a kml file containing location data pertinent to the individual user. The KML file is generated and saved successfully.However, the data is not displayed on the map (no errors arise).This is the file which queries the DB and generates the KML.\[code\] <?phpsession_start();if(isset($_SESSION['login'])){$userID = ($_SESSION['login']);header("Content-type: application/vnd.google-earth.kml+xml");header("Content-disposition: inline; filename=$userID.kml");$con=mysql_connect("****", "****", "****");mysql_select_db("****");if ($userID!=null){$sql1="SELECT * FROM user WHERE userID='$userID'";$result1 = mysql_query($sql1, $con);} if (!$result1){ die ('Invalid Query: ' . mysql_error()); }$devIDrow = mysql_fetch_assoc($result1);$devIDquery = $devIDrow['uuid'];$name = $devIDrow['name'];$sql2="SELECT * FROM gps WHERE devID='$devIDquery'";$result2 = mysql_query($sql2, $con); if (!$result2) { die ('Invalid Query: ' . mysql_error()); }$dom = new DOMDocument('1.0', 'UTF-8');$dom->formatOutput = true;// Iterate through the rows, adding KML nodes for each// Creates the root KML element and appends it to the root document.$node = $dom->createElementNS('http://www.opengis.net/kml/2.2', 'kml');$parNode = $dom->appendChild($node);// Creates a KML Document element and append it to the KML element.$dnode = $dom->createElement('Document');$docNode = $parNode->appendChild($dnode);while ($row = mysql_fetch_assoc($result2)){ $dnode = $dom->createElement("Placemark"); $newnode = $docNode->appendChild($dnode); $newnode = $dom->createElement("displayName"); $newnode->nodeValue = http://stackoverflow.com/questions/15583292/$name; $dnode->appendChild($newnode); $newnode = $dom->createElement("Description"); $newnode->nodeValue = http://stackoverflow.com/questions/15583292/$row['logTime']; $dnode->appendChild($newnode); //Coordinates are a child node of the 'Point' node $pointnode = $dom->createElement("Point"); $dnode->appendChild($pointnode); $coordsnode = $dom->createElement("Coordinates"); $coordsnode->nodeValue = http://stackoverflow.com/questions/15583292/$row['latitude'].",".$row['longitude']; $pointnode->appendChild($coordsnode);}}$filename = $userID.".kml";$dom->save($filename);mysql_close($con2);header("location:mapsNokia.php");?>\[/code\]The following is the page which loads up the map\[code\]<?phpsession_start();$userID = $_SESSION['login'];header('Access-Control-Allow-Origin: *');?><!DOCTYPE html><html xmlns ="http://www.w3.org/1999/xhtml"> <head> <title>3D Protect - Map</title> <link rel="stylesheet" type="text/css" href="http://stackoverflow.com/questions/15583292/style.css" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=7" ; IE=EmulateIE9/></head><body> <nav> <ul class="fancyNav"> <li id="home"><a href="http://www.3dprotectsoftware.com/index" class="homeIcon">Home</a></li> <li id="login"><a href="http://www.3dprotectsoftware.com/login">Login</a></li> <li id="store"><a href="http://www.store.3dprotectsoftware.co.uk/index.php?route=product/product&filter_name=nfc&product_id=50">Store</a></li> <li id="about"><a href="http://www.3dprotectsoftware.com/aboutus">About Us</a></li> <li id="contact"><a href="http://www.3dprotectsoftware.com/contact">Contact Us</a></li> </ul> </nav> </ul><script type="text/javascript" src="http://api.maps.nokia.com/2.2.4/jsl.js?with=all" charset="utf-8"></script><div id="map" style="z-index: -1; left:25%; right: 25%; top:25%; bottom: 25%; width: 50%; height: 50%; position: absolute;"></div><script type="text/javascript">/*<![CDATA[*//////////////////////////////////////////////////////////////////////////////////////// Don't forget to set your API credentials//// Replace with your appId and token which you can obtain when you // register on http://api.developer.nokia.com/ // nokia.Settings.set( "", ""); nokia.Settings.set( "", "");// /////////////////////////////////////////////////////////////////////////////////////var map = new nokia.maps.map.Display(document.getElementById("map"), { components: [ new nokia.maps.map.component.Behavior(), new nokia.maps.map.component.ZoomBar(), new nokia.maps.map.component.Overview(), new nokia.maps.map.component.TypeSelector(), new nokia.maps.map.component.ScaleBar(), new nokia.maps.map.component.InfoBubbles() ], 'zoomLevel': 15, 'center': [54.04541,-2.79916] }); var kml = new nokia.maps.kml.Manager(); // We define a callback function for parsing kml file, // and then push the parsing result to map display var onParsed = function (kmlManager) { var resultSet; // KML file was successfully loaded if (kmlManager.state == "finished") { // KML file was successfully parsed resultSet = new nokia.maps.kml.component.KMLResultSet(kmlManager.kmlDocument, map); resultSet.addObserver("state", function (resultSet) { if (resultSet.state == "finished") { // Retrieve map objects container from KML resultSet container = resultSet.container; // Add the container to the map's object collection so they will be rendered onto the map. map.objects.add(container); // Switch the viewport of the map do show all KML map objects within the container map.zoomTo(container.getBoundingBox()); } }); resultSet.create(); } }; // Add an observer to kml manager kml.addObserver("state", onParsed);kml.parseKML("http://www.3dprotectsoftware.com/"+'<?php $userID = $_SESSION['login']; echo $userID;?>.kml');</script></body></html>\[/code\]I dont know why the data is not being displayed.Below is a sample kml file\[code\]<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <Placemark> <Name>Antwan</Name> <Description>2013-03-18 20:56:39</Description> <Point> <Coordinates>54.04541,-2.79916</Coordinates> </Point> </Placemark> <Placemark> <Name>Antwan</Name><Description>2013-03-18 21:01:42</Description> <Point> <Coordinates>54.04541,-2.79916</Coordinates> </Point> </Placemark></Document></kml>\[/code\]Any help would be greatly appreciated
 
Top