1

My Google maps are configured to display blue location markers.

My maps use the following .kml file (just xml data describing places to show blue location markers via the Google Maps API), which I load with a plain old XMLHttpRequest object.

My issue is this, when I load the .kml file from an external source such as "http://xyz.com/kumedplaces.kml", it works, but when I store it and try to load it from the local server that my sitecore website runs, the Google Map Object doesn't load/show the blue location markers on the map.

Below is what I do in my .js file after loading the addresses from the .kml file:

 <div id="map" style="width: 400px; height: 300px"></div>

    var kmlUrl = "http://xyz.com/kumedplaces.kml";  works
    var kmlUrl = "/js/heart/kumedplaces.kml";   doesn't work

    var geoXml = new GGeoXml(kmlUrl);
    map.addOverlay(geoXml);

and by the way I did double check on my local to make sure my local .kml file is loading correctly

Sample of my .kml file:

 <?xml version="1.0" encoding="utf-8" ?> 
    <kml xmlns="http://earth.google.com/kml/2.1">
      <Document>
        <name>University of Kansas Hospital Locations</name>
        <description>The various buildings around the city that comprise the University of Kansas Hospital</description>

    <Style id="randomColorIcon">
      <IconStyle>
        <color>ff00ff00</color>
        <colorMode>random</colorMode>
        <scale>1.1</scale>
        <Icon>
          <href>http://maps.google.com/mapfiles/kml/pal3/icon21.png</href>
        </Icon>
      </IconStyle>
    </Style>

    <Placemark id="kumed">
      <name>The University of Kansas Hospital</name>
      <description>
        Part of the Kansas University Medical Center complex.
        3901 Rainbow Blvd, Kansas City, KS 66160
      </description>
      <address>3901 Rainbow Blvd, Kansas City, KS 66160</address>
      <phonenumber>xxxxxxx</phonenumber>
      <ExtendedData></ExtendedData>
      <!--<styleUrl>#randomColorIcon</styleUrl>-->
      <Point>
        <coordinates>-94.608800,39.0558241</coordinates>
      </Point>
    </Placemark>
  </Document>   
</kml>
m0rtimer
  • 2,023
  • 1
  • 25
  • 31
Nazo Tajrian
  • 131
  • 2
  • 14

3 Answers3

0

It looks like the KML file cannot be kept, or at least referenced, locally. See this other question. Instead of an absolute path, try appending your HTTP domain to the beginning of the file path? (e.g. http://yourdomain.com/js/heart/kumedplaces.kml)

Community
  • 1
  • 1
Matt
  • 22,721
  • 17
  • 71
  • 112
0

KML files need to be publicly accessible (as they need to be read in by Google servers), as far as I'm aware you can't have local references to KML files (as Google wont know where to look for them).

Stephen Pope
  • 3,551
  • 1
  • 17
  • 21
0

You need to add the correct MIME types to your webserver to serve kml and kmz files.

For kml - application/vnd.google-earth.kml+xml

For kmz - application/vnd.google-earth.kmz

Assuming you're using IIS7, add these under Mime Types in the IIS7 manager.

Adam Hopkinson
  • 28,281
  • 7
  • 65
  • 99