Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#谷歌地球错误_C#_Controls_Google Earth Plugin - Fatal编程技术网

C#谷歌地球错误

C#谷歌地球错误,c#,controls,google-earth-plugin,C#,Controls,Google Earth Plugin,我的一个朋友在C#用户控件中嵌入了一个google earth插件。一切正常,但当您关闭窗口时,我们会收到“未指定错误”,并选择是否继续运行脚本。从我们对它的追踪来看,这似乎是由谷歌在页面上投放的一个脚本造成的。有什么想法吗?我们现在已经在IE和FF中尝试过了。很好。你知道为什么这个错误只会在近距离出现吗?我们能不能禁用它?这是我们的代码 <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <

我的一个朋友在C#用户控件中嵌入了一个google earth插件。一切正常,但当您关闭窗口时,我们会收到“未指定错误”,并选择是否继续运行脚本。从我们对它的追踪来看,这似乎是由谷歌在页面上投放的一个脚本造成的。有什么想法吗?

我们现在已经在IE和FF中尝试过了。很好。你知道为什么这个错误只会在近距离出现吗?我们能不能禁用它?这是我们的代码

<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<html>
<head>
    <script src="http://www.google.com/jsapi?key=ABQIAAAAzghEPRV_D0MDzTELJ4nkXBT2AlVLQD8Rz4_aVbiXesLoyhRIMBRo399nnxv9aY-fqnkVGgTgR-pTsg">
    </script>
    <script>
        google.load("earth", "1");
        var ge = null;
        var placemark;
        function init(){
            google.earth.createInstance("map3d", initCallback, failureCallback);
        }

        function initCallback(object){
            ge = object;
            ge.getWindow().setVisibility(true);
            ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);
            ge.getLayerRoot().enableLayerById(ge.LAYER_TERRAIN, false);

            placemark = ge.createPlacemark('');
            placemark.setName("Current Position");
            // Create style map for placemark
            var normal = ge.createIcon('');
            normal.setHref('http://maps.google.com/mapfiles/kml/paddle/red-circle.png');
            var iconNormal = ge.createStyle('');
            iconNormal.getIconStyle().setIcon(normal);
            var highlight = ge.createIcon('');
            highlight.setHref('http://maps.google.com/mapfiles/kml/paddle/red-circle.png');
            var iconHighlight = ge.createStyle('');
            iconHighlight.getIconStyle().setIcon(highlight);
            var styleMap = ge.createStyleMap('');
            styleMap.setNormalStyle(iconNormal);
            styleMap.setHighlightStyle(iconHighlight);
            placemark.setStyleSelector(styleMap);

            var options = ge.getOptions();

            options.setStatusBarVisibility(true);
            options.setScaleLegendVisibility(true);
        }

        function failureCallback(object){
            // Gracefully handle failure.
            alert("Error");
        }

        function changeViewAngle(angle){
            var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_ABSOLUTE);
            lookAt.setTilt(angle);
            ge.getView().setAbstractView(lookAt);
        }

        function ShowMarker(){
            ge.getFeatures().appendChild(placemark);
        }

        function MoveMarker(lon, lat){
            // Create point
            var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
            var point = ge.createPoint('');
            point.setLatitude(lat);
            point.setLongitude(lon);
            placemark.setGeometry(point);
        }

        function HideMarker(){
            ge.getFeatures().removeChild(placemark);
        }

        function SetPosition(lon, lat, heading){
            var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
            lookAt.setLatitude(lat);
            lookAt.setLongitude(lon);
            lookAt.setHeading(heading);
            ge.getView().setAbstractView(lookAt);
        }

        function SetAltitude(alt){
            var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
            lookAt.set(lookAt.getLatitude(), lookAt.getLongitude(), 0, ge.ALTITUDE_RELATIVE_TO_GROUND, 0, lookAt.getTilt(), alt);
            ge.getView().setAbstractView(lookAt);
        }

        function ResizeMap(w, h){
            var map = document.getElementById('map3d_container');
            map.style.height = h;
            map.style.width = w;
        }

        function AddKML(kml){
            var parseKML = ge.parseKml(kml);
            ge.getFeatures().appendChild(parseKML);
            return ge.getFeatures().getLastChild().getName();
        }

        function RemoveKML(kmlName){
            if (ge.getFeatures().hasChildNodes()) {
                var nodes = ge.getFeatures().getChildNodes();
                for (var i = 0; i < nodes.getLength(); i++) {
                    var child = nodes.item(i);
                    if (child.getName() == kmlName) {
                        ge.getFeatures().removeChild(child);
                    }
                }
            }
        }

        function OptionsChanged(nav, status, scale, grid, map, terrain, road, border, building){
            var options = ge.getOptions();
            var form = document.options;

            if (nav) {
                ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);
            }
            else {
                ge.getNavigationControl().setVisibility(ge.VISIBILITY_HIDE);
            }

            options.setStatusBarVisibility(status);
            options.setScaleLegendVisibility(scale);
            options.setGridVisibility(grid);
            options.setOverviewMapVisibility(map);
            ge.getLayerRoot().enableLayerById(ge.LAYER_TERRAIN, terrain);
            ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, road);
            ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, border);
            ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS, building);
        }



    </script>
</head>
<body onload='init()'>
    <center>
        <div id='map3d_container' style='border: 1px solid silver; height: 510px; width: 767px;'>
            <DIV id=map3d style="HEIGHT: 100%">
            </DIV>
        </div>
    </center>
</body>
</html>

谷歌加载(“地球”,“1”);
var ge=null;
var-placemark;
函数init(){
createInstance(“map3d”、initCallback、failureCallback);
}
函数initCallback(对象){
ge=对象;
ge.getWindow().setVisibility(true);
ge.getNavigationControl().setVisibility(ge.VISIBILITY\u SHOW);
ge.getLayerRoot().enableLayerById(ge.LAYER\u地形,false);
placemark=ge.createPlacemark(“”);
placemark.setName(“当前位置”);
//为placemark创建样式图
var normal=ge.createIcon(“”);
normal.setHref('http://maps.google.com/mapfiles/kml/paddle/red-circle.png');
var iconNormal=ge.createStyle(“”);
iconNormal.getIconStyle().setIcon(正常);
var highlight=ge.createIcon(“”);
highlight.setHref('http://maps.google.com/mapfiles/kml/paddle/red-circle.png');
var iconHighlight=ge.createStyle(“”);
iconHighlight.getIconStyle().setIcon(高亮显示);
var styleMap=ge.createStyleMap(“”);
setNormalStyle(iconNormal);
styleMap.setHighlightStyle(iconHighlight);
placemark.setStyleSelector(样式映射);
var options=ge.getOptions();
options.setStatusBarVisibility(true);
选项。setScaleLegendVisibility(true);
}
函数失败回调(对象){
//优雅地处理失败。
警报(“错误”);
}
函数更改视角(角度){
var lookAt=ge.getView();
注视。设置倾斜(角度);
ge.getView().setAbstractView(lookAt);
}
函数ShowMarker(){
ge.getFeatures().appendChild(placemark);
}
功能移动标记(lon、lat){
//创建点
var la=ge.getView().copyAsLookAt(相对于地面的高度);
var point=ge.createPoint(“”);
设置纬度(lat);
点经度(lon);
placemark.setGeometry(点);
}
函数HideMarker(){
ge.getFeatures().removeChild(placemark);
}
功能设置位置(纵向、横向、航向){
var lookAt=ge.getView().copyaslokat(相对于地面的高度);
注视。设置纬度(纬度);
看,经度(lon);
注视。设定航向(航向);
ge.getView().setAbstractView(lookAt);
}
功能设置高度(alt){
var lookAt=ge.getView().copyaslokat(相对于地面的高度);
lookAt.set(lookAt.getLatitude(),lookAt.getLongitude(),0,ge.ALTITUDE\u相对地面,0,lookAt.getTilt(),alt);
ge.getView().setAbstractView(lookAt);
}
函数ResizeMap(w,h){
var map=document.getElementById('map3d_容器');
map.style.height=h;
map.style.width=w;
}
函数AddKML(kml){
var parseKML=ge.parseKML(kml);
ge.getFeatures().appendChild(parseKML);
返回ge.getFeatures().getLastChild().getName();
}
函数RemoveKML(kmlName){
if(ge.getFeatures().hasChildNodes()){
var nodes=ge.getFeatures().getChildNodes();
对于(var i=0;i
我运行了示例,在关闭选项卡时没有出现任何错误。

试试这个

yourWebBrowser1.Document.Write(String.Empty)

当你关闭应用程序时

我的问题: 你能告诉我如何在C#app中使用AddKML(kml)吗?通过字符串或文件路径,我尝试了两者。
我正在寻找一种方法来解析kml文件

我举了一个c#/Google Earth API集成的例子,它涵盖了您遇到的问题(请参见评论)

另外,这里是我的另一个项目,它使用COM Google Earth插件类型库(Plugin_ax.dll)转换为公共语言运行时程序集中的等效定义。它可能有一些用处