zoukankan      html  css  js  c++  java
  • VEMap.DeleteAllShapeLayers 方法

    来源:https://msdn.microsoft.com/zh-cn/library/bb412514.aspx

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
       <head>
          <title></title>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
          <script type="text/javascript" src="http://dev.ditu.live.com/mapcontrol/mapcontrol.ashx?v=6.2"></script>
    
          <script type="text/javascript">
             var map = null;
             var layer01 = null;
             var layer02 = null;
             var shape01 = null;
             var shape02 = null;
             var id01 = null;
             var id02 = null;
             var layer = null;
             
             function GetMap()
             {
                map = new VEMap('myMap');
                map.LoadMap();
    
                map.AttachEvent("onclick", ShapeLayerAlert);
             }
             
             function AddShapeLayers()
             {
                var points01 = new Array(
                   new VELatLong(45.01188,-111.06687),
                   new VELatLong(45.01534,-104.06324),
                   new VELatLong(41.01929,-104.06),
                   new VELatLong(41.003,-111.05878),
                   new VELatLong(45.01188,-111.06687)
                );
                
                var points02 = new Array(
                   new VELatLong(43.01188,-109.06687),
                   new VELatLong(43.01534,-101.06324),
                   new VELatLong(39.01929,-101.06),
                   new VELatLong(39.003,-109.05878),
                   new VELatLong(43.01188,-109.06687)
                );
                
                layer01 = new VEShapeLayer();
                layer01.SetTitle("layer01 title");
                map.AddShapeLayer(layer01);
                
                layer02 = new VEShapeLayer();
                layer02.SetTitle("layer02 title");
                map.AddShapeLayer(layer02);
                
                shape01 = new VEShape(VEShapeType.Polygon, points01);
                shape01.SetLineWidth(3);
                shape01.SetLineColor(new VEColor(0,150,100,1.0));
                shape01.SetFillColor(new VEColor(0,150,100,0.5));
                layer01.AddShape(shape01);
                
                shape02 =  new VEShape(VEShapeType.Polygon, points02);
                shape02.SetLineWidth(3);
                shape02.SetLineColor(new VEColor(0,100,150,1.0));
                shape02.SetFillColor(new VEColor(0,100,150,0.5));
                layer02.AddShape(shape02);
                
                map.SetMapView(points01);
                
                id01 = shape01.GetID();
                id02 = shape02.GetID();
                
                var links = "Delete: <a href='#' onClick='DeleteOneShape(id01)'>" + id01 + "</a><br/>";
                links += "Delete: <a href='#' onClick='DeleteOneShape(id02)'>" + id02 + "</a>";
                shapeLinks.innerHTML = links;    
                
                ShapeLayerInfo();        
             }
    
             function DeleteShapeLayer(layer)
             {
                map.DeleteShapeLayer(layer);
                ShapeLayerInfo();
             }
             
             function DeleteAllLayers()
             {
                map.DeleteAllShapeLayers();
                ShapeLayerInfo();
             }
             
             function DeleteAllShapes()
             {
                map.DeleteAllShapes();
             }
             
             function DeleteOneShape(id)
             {
                shape = map.GetShapeByID(id);
                map.DeleteShape(shape);
                alert("Shape ID: " + id + " has been deleted.");
             }    
             
             function ShapeLayerInfo()
             {
                var layers = "Number of shape layers: " + map.GetShapeLayerCount() + " (including the base layer)";
                layerInfo.innerHTML = layers;
             }  
             
             function ShapeLayerAlert(e)
             {
                if(e.elementID != null)
                {
                   shape = map.GetShapeByID(e.elementID);
                   layer = shape.GetShapeLayer();
                   alert("Shape ID " + shape.GetID() + "
    belongs to shape layer '" + layer.GetTitle() + "'.");
                }
             }
          </script>
       </head>
       <body onload="GetMap();" style="font-family:Arial">
          <div id='myMap' style="position:relative; 400px; height:400px;"></div>
          <div id="shapeLinks"></div>
          <div id="layerInfo"></div>
           <INPUT id="addshapelayers" type="button" value="Click to Add Shape Layers" name="addshapelayers"
           onclick="AddShapeLayers();"/>
           <INPUT id="deletelayer01" type="button" value="Click to Delete layer01" name="deletelayer01"
           onclick="DeleteShapeLayer(layer01);"/>
           <INPUT id="deletelayer02" type="button" value="Click to Delete layer02" name="deletelayer02"
           onclick="DeleteShapeLayer(layer02);"/>
           <INPUT id="deletealllayers" type="button" value="Click to Delete All Layers" name="deletealllayers"
           onclick="DeleteAllLayers();"/>
           <INPUT id="deleteallshapes" type="button" value="Click to Delete All Shapes" name="deleteallshapes"
           onclick="DeleteAllShapes();"/><br />
       </body>
    </html>

    想了解更多关于VEMap类的详细内容,参见:https://msdn.microsoft.com/zh-cn/library/bb429586.aspx

  • 相关阅读:
    Fragment使用具体解释
    2014百度之星第一题Energy Conversion
    HDU 2602 Bone Collector 0/1背包
    Angular 2 + 折腾记 :(7) 初步了解表单:模板驱动及数据驱动及脱坑要点
    《开源框架那点事儿25》:对框架模板引擎实现方式的改造实录
    ROS机器人程序设计(原书第2版)补充资料 (柒) 第七章 3D建模与仿真 urdf Gazebo V-Rep Webots Morse
    sql改写or 改成union不等价数据变多
    在GDAL中添加GDALRasterizeGeometriesBuf函数
    多时相地图瓦片简单设想
    记录一次使用VS2015编译错误的原因查找(boost+gdal)
  • 原文地址:https://www.cnblogs.com/144823836yj/p/5537893.html
Copyright © 2011-2022 走看看