Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--
- You are free to copy and use this sample in accordance with the terms of the
- Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
- -->
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
- <title>Google Earth API Sample</title>
- <script src="http://www.google.com/jsapi?key=ABQIAAAAuPsJpk3MBtDpJ4G8cqBnjRRaGTYH6UMl8mADNa0YKuWNNa8VNxQCzVBXTx2DYyXGsTOxpWhvIG7Djw" type="text/javascript"></script>
- <script type="text/javascript">
- function addSampleButton(caption, clickHandler) {
- var btn = document.createElement('input');
- btn.type = 'button';
- btn.value = caption;
- if (btn.attachEvent)
- btn.attachEvent('onclick', clickHandler);
- else
- btn.addEventListener('click', clickHandler, false);
- // add the button to the Sample UI
- document.getElementById('sample-ui').appendChild(btn);
- }
- function addSampleUIHtml(html) {
- document.getElementById('sample-ui').innerHTML += html;
- }
- </script>
- <script type="text/javascript">
- var ge;
- google.load("earth", "1");
- google.load("maps", "2");
- function init() {
- google.earth.createInstance('map3d', initCallback, failureCallback);
- addSampleUIHtml(
- '<input id="location" type="text" value="kosice, matuskova 12"/>'
- );
- addSampleButton('Fly Here!', buttonClick)
- }
- function initCallback(instance) {
- ge = instance;
- ge.getWindow().setVisibility(true);
- // add a navigation control
- ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
- // add some layers
- ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
- ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);
- // in this sample we will attempt
- // to fetch a KML file and show it
- function finished(object) {
- if (!object) {
- // wrap alerts in API callbacks and event handlers
- // in a setTimeout to prevent deadlock in some browsers
- setTimeout(function() {
- alert('Bad or null KML.');
- }, 0);
- return;
- }
- ge.getFeatures().appendChild(object);
- // var la = ge.createLookAt('');
- // la.set(48.724944, 21.246872, 25, ge.ALTITUDE_RELATIVE_TO_GROUND,
- // 180, 60, 500);
- // ge.getView().setAbstractView(la);
- }
- // fetch the KML
- var url = 'http://3dmodel.fei.tuke.sk/Dominikanske_namestie_49.kmz';
- google.earth.fetchKml(ge, url, finished);
- google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/Dom_umenia.kmz', finished);
- google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/masiarska_40.kmz', finished);
- google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/masiarska_42.kmz', finished);
- google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/masiarska_46_50.kmz', finished);
- google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/masiarska_52_56.kmz', finished);
- google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/masiarska_58az60.kmz', finished);
- google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/masiarska_59.kmz', finished);
- google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/masiarska_62az72.kmz', finished);
- google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/masiarska_72_74.kmz', finished);
- document.getElementById('installed-plugin-version').innerHTML =
- ge.getPluginVersion().toString();
- }
- function failureCallback(errorCode) {
- }
- function buttonClick() {
- var geocodeLocation = document.getElementById('location').value;
- var geocoder = new google.maps.ClientGeocoder();
- geocoder.getLatLng(geocodeLocation, function(point) {
- if (point) {
- var lookAt = ge.createLookAt('');
- lookAt.set(point.y, point.x, 10, ge.ALTITUDE_RELATIVE_TO_GROUND,
- 0, 90, 100);
- ge.getView().setAbstractView(lookAt);
- }
- });
- }
- </script>
- </head>
- <body onload="init()" style="font-family: arial, sans-serif; font-size: 13px; border: 0;">
- <div id="sample-ui"></div>
- <div id="map3d" style="width: 1024px; height: 768px;"></div>
- <br>
- <div>Installed Plugin Version: <span id="installed-plugin-version" style="font-weight: bold;">Loading...</span></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement