Google Map KML file in Asp.Net

Asked By Shailendrasinh Parmar
02-Feb-10 09:07 AM
Earn up to 0 extra points for answering this tough question.
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());
                    map.addOverlay(geoXml);
                    map.setCenter(geoXml.getDefaultCenter()); 
                    geoXml.gotoDefaultViewport(map);
                  }
                }

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..

  re: Google Map KML file in Asp.Net

Sean * replied to Shailendrasinh Parmar
02-Feb-10 12:20 PM
Would it be possible to post your "myKML.kml" here or link to it, as you say the code you posted works already.

  I'm neither Peter nor Mr. Robbe Morris.

[)ia6l0 iii replied to Shailendrasinh Parmar
02-Feb-10 02:55 PM
However, in my opinion, the KML url that you are using needs to available on the internet, as it is processed by the Google Servers before the browser processes it. So the localhost url's are skipped.

There is an explanation provided here.

  re: re: Google Map KML file in Asp.Net

Shailendrasinh Parmar replied to Sean *
02-Feb-10 11:52 PM
Hello, Here is the content of mykml.kml

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
  <Document>
    <Placemark>
      <name>Lowes #3</name>
      <styleUrl>root://styleMaps#default+nicon=0x447+hicon=0x457</styleUrl>
      <Point>
        <coordinates>82.831893,39.920836,0</coordinates>
      </Point>
      <LookAt>
        <longitude>82.831893</longitude>
        <latitude>39.920836</latitude>
        <longitude>45.000000</longitude>
      </LookAt>
    </Placemark>
    <Placemark>
      <name>Lowes #9</name>
      <styleUrl>root://styleMaps#default+nicon=0x447+hicon=0x457</styleUrl>
      <Point>
        <coordinates>82.741163,40.363952,0</coordinates>
      </Point>
      <LookAt>
        <longitude>82.741163</longitude>
        <latitude>40.363952</latitude>
        <longitude>45.000000</longitude>
      </LookAt>
    </Placemark>
    <Placemark>
      <name>Lowes #16</name>
      <styleUrl>root://styleMaps#default+nicon=0x447+hicon=0x457</styleUrl>
      <Point>
        <coordinates>87.480207,37.334623,0</coordinates>
      </Point>
      <LookAt>
        <longitude>87.480207</longitude>
        <latitude>37.334623</latitude>
        <longitude>45.000000</longitude>
      </LookAt>
    </Placemark>
    <Placemark>
      <name>Lowes #22</name>
      <styleUrl>root://styleMaps#default+nicon=0x447+hicon=0x457</styleUrl>
      <Point>
        <coordinates>76.43317,40.298283,0</coordinates>
      </Point>
      <LookAt>
        <longitude>76.43317</longitude>
        <latitude>40.298283</latitude>
        <longitude>45.000000</longitude>
      </LookAt>
    </Placemark>
  </Document>
</kml>
Create New Account