C# .NET - Google Map KML file in Asp.Net - Asked By Shailendrasinh Parmar on 03-Feb-10 03:06 AM

I am creating KML file for google maps, and the file is generating properly in the same directory. But When I use it in my page, it doesn't show proper map.

Here is my code in javascript 

function init()
                    if (GBrowserIsCompatible()) {
                    geoXml = new GGeoXml("http://localhost:1546/Website1/myKML.kml");
                    //geoXml = new GGeoXml("http://www.spencerwilliams.net/kml/kmltest3.xml");
   map = new GMap2(document.getElementById("map_canvas"));
                    map.setCenter(new GLatLng(0,0),0);      
                    map.addControl(new GLargeMapControl());
                    map.addControl(new GLargeMapControl());

This function is being called on Body's onload event.

When I used following statement in it, the map was showing proper locations.

//geoXml = new GGeoXml("http://www.spencerwilliams.net/kml/kmltest3.xml");

Can anybody guide me further please, Peter sir and Mr. Robbe Morris?

Thanks in Advance..
Sreekumar P replied to Shailendrasinh Parmar on 03-Feb-10 03:22 AM
u cannot create file in another domain. ( For that u should have cross domain features)


geoXml = new GGeoXml("kmltest3.xml");

but this shlould be hosted on the
spencerwilliams.net doiman. or if in localhost will work also

Shailendrasinh Parmar replied to Sreekumar P on 03-Feb-10 04:01 AM
I tried the code you suggested, just applying the kml file name in GGeoXml function. But it doesn't show proper map...

integrating KML into Website - mv ark replied to Shailendrasinh Parmar on 03-Feb-10 04:37 AM

I guess, to integrate the KML file into a web page, you would need to have a Google Maps API Key for the specific domain that you want it to work for. Have you used that already?

Check this tutorial on integrating KML into Websites for step by step instructions - http://www.webtools.ca.gov/Multimedia/Maps.asp