Hello! I'm having an issue that I've now been working with for several hours. I'm completely stumped, so I hope that one of you might be able to give me a tip.
I am trying to display a polygon from a database. (Just one, at the moment, for testing, but more in the future. It has to be able to display various polygons depending on conditions the user will input, so flat KML is not an option.) I have a PHP script that outputs the points of the polygon into a proper KML format. (http://myfarms.org/test/upload_from_db.php) Initially, I assumed that I just needed to link to the script as I linked to a flat KML file in my testing: var kml = new google.maps.KmlLayer('http://myfarms.org/test/ upload_from_db.php', { map: map }); However, this resulted in the map jumping to a zoomed-out view of the entire world. (Anyone know why this is?) As a way of checking the KML being outputted, I copied the entire source of what was produced by the script and pasted it into a KML file. Then I used the above method to link to said file (http:// myfarms.org/test/tenn2.kml). It worked! So the KML being output is fine it just... can't read it when the file extension is not .kml? I did some more research, and came across information from the tutorial (http://code.google.com/apis/kml/articles/ phpmysqlkml.html#outputkml) that suggested using a Network Link to link between the javascript and the PHP script. So, I created a very simple KML file that linked to my upload_from_db.php script: <?xml version='1.0' encoding='UTF-8'?> <kml xmlns = 'http://earth.google.com/kml/2.1'> <Folder> <NetworkLink> <Link> <href>http://myfarms.org/test/upload_from_db.php</href> </Link> </NetworkLink> </Folder> </kml> Then I pointed to this from my javascript. The result? The same old zoomed-out map of earth. Then I had an errant thought: what happens if I swap out my flat KML file, tenn2.kml, for the upload_from_db.php in the network link. It works again, yay! But that doesn't really help me much, it just tells me that my network link file actually works when it's pointed at something that I already know works. Finally, I tried putting the KML on the map with "addOverlay", but that simply did not work at all. This is what I inserted into my initialize function: var geoXml = new google.maps.GGeoXml('http://myfarms.org/test/ upload_from_db.php'); map.addOverlay(geoXml); I tried several variations of this, using the network link KML file, the php script as you see there, and the tenn2.kml file. I swapped out google.maps.GGeoXML for google.maps.KmlLayer, I tried "GGeoXml" by itself (without the google.maps)... in the end, I probably just have no idea what I'm doing when it comes to addOverlay. I hope all of that was clear and easy to follow. My test page can be seen here: http://myfarms.org/test/googlemap_test.html It should show how it always zooms out to the world instead of creating the polygon. If you have any advice that can help me, please share! Thanks very much, Jen -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
