The Documentation for Google Earth says I should be able to access files on my local drive, yet i cannot find an example and when I try to use the KML on my local drive it doesn't seem to be loading. I see a lot of answers saying it can't be done, But why does the Documentation say otherwise?
My Code
var href = 'http://code.google.com/'
+ 'D:/visual studio 12/Projects/myMap/myMap/myPoints.Kml';
Example
Network Links
A network link contains a element with an (a hypertext reference) that loads a file. The can be a local file specification or an absolute URL. Despite the name, a does not necessarily load files from the network. The in a link specifies the location of any of the following: •An image file used by icons in icon styles, ground overlays, and screen overlays •A model file used in the element •A KML or KMZ file loaded by a Network Link
The specified file can be either a local file or a file on a remote server. In their simplest form, network links are a useful way to split one large KML file into smaller, more manageable files on the same computer.
So far, all of our examples have required that the KML code be delivered to Google Earth from the local machine. Network links give you the power to serve content from a remote location and are commonly used to distribute data to large numbers of users. In this way, if the data needs to be amended, it has to be changed only at the source location, and all users receive the updated data automatically.
I have done some changeing and testing and figured out the error has to be in my HTML file not in the KML file. If I click on the HTML file I get the same results as I do running my program.
Am I correct in thinking that you run your HTML file and it should call the KML? Or do I just call the KML to open GE?
This is my Sample HTML I am tring to make run.
<!DOCTYPE html>
<html>
<head>
<title>Sample</title>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
var ge;
google.load("earth", "1.x");
function init() {
google.earth.createInstance('map3d', initCB, failureCB);
};
function initCB(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
var href = 'https://dl.dropbox.com/u/61240296/myPoints.Kml';
google.earth.fetchKml(ge, href, kmlFinishedLoading);
};
function kmlFinishedLoading(obj) {
kmlObject = obj;
if (kmlObject) {
if ('getFeatures' in kmlObject) {
kmlObject.getFeatures().appendChild(placemark);
}
ge.getFeatures().appendChild(kmlObject);
if (kmlObject.getAbstractView()) {
ge.getView().setAbstractView(kmlObject.getAbstractView());
}
}
};
function showHideKml() {
kmlObject.setVisibility(!kmlObject.getVisibility());
};
function failureCB(errorCode){};
google.setOnLoadCallback(init);
</script>
</head>
<body>
<div id="map3d" style="height: 320px; width: 679px;">
</div>
</body>
</html>
local file specification, it doesn't mean a local file on your machine - it means a relative path on the domain. See my answer for a fuller explanation. - Fraser