文档详情

Google API 使用示例.docx

发布:2017-08-07约7.56千字共7页下载文档
文本预览下载声明
Google API 使用示例1、调用Google earth 的完整示例htmlheadtitleSample/titlescriptsrc=/jsapi?key=ABCDEFG/scriptscripttype=text/javascriptvar ge; google.load(earth,1);function init(){ google.earth.createInstance(map3d, initCB, failureCB);}function initCB(instance){ ge = instance; ge.getWindow().setVisibility(true);}function failureCB(errorCode){} google.setOnLoadCallback(init);/script/headbodydivid=map3dstyle=height:400px;width:600px;/div/body/html2、设置图片地标// Create the placemark.var placemark = ge.createPlacemark();placemark.setName(placemark);// Define a custom icon.var icon = ge.createIcon();icon.setHref(/mapfiles/kml/paddle/red-circle.png);var style = ge.createStyle();//create a new stylestyle.getIconStyle().setIcon(icon);//apply the icon to the styleplacemark.setStyleSelector(style);//apply the style to the placemark// Set the placemarks location. var point = ge.createPoint();point.setLatitude(12.345);point.setLongitude(54.321);placemark.setGeometry(point);// Add the placemark to Earth.ge.getFeatures().appendChild(placemark);//设置图片的大小style.getIconStyle().setScale(5.0);3、自动调用地标说明(1)下例将setBalloon()移入自身的函数中,以便能通过点击按钮来调用。请注意,必须将placemark定义为全局变量,以便在showBalloon()函数的作用域中使用。scripttype=text/javascriptvar ge;var placemark; google.load(earth,1);function init(){ google.earth.createInstance(map3d, initCB, failureCB);}function initCB(instance){ ge = instance; ge.getWindow().setVisibility(true); ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);// Create the placemark. placemark = ge.createPlacemark(); placemark.setDescription(img src=/intl/en_ALL/images/logo.gif height=25px width=75px+pemFeature balloons/em accept most HTML./p+table border=1pxtrthAllowed/ththNot allowed/th/tr+trtdTables/tdtdIFRAMEs/td/tr+trtdFont styles/tdtd#60;embed#62; and #60;object#62; tags/td/tr+trtdetc.../tdtdnbsp;/td/tr/table+pCSS and JavaScript are not supported./p);// Set the placemarks location.var point = ge.createPoint(); point.set
显示全部
相似文档