How to Call a KML From JavaScript
KML is the standard language to transfer geographical locations in applications such as Web apps. Google uses KML for the company's Google Maps organization. You can call KML in JavaScript to open a map and display a geographic location in your website. This is beneficial when you have a physical address for your business and you want users to have a map to the location.
Instructions
-
-
1
Right-click the HTML file you want to use to display the KML map information. Click "Open With," and then click your preferred HTML editor
-
2
Include the Google script for the KML functions. Add the following code at the beginning of your script section:
<script src="https://www.google.com/jsapi?key=yourkey"></script>
Replace "yourkey" with your unique Google key for Google apps.
-
-
3
Open the KML map. The following code opens a map to an address:
google.earth.createInstance('mylocation', initCallback, failureCallback);
Replace "mylocation" with the address you want to use.
-
4
Display the map. The following code displays the map:
map = pluginInstance;
map.getWindow().setVisibility(true);
-
1