• 高德地图API事件-鼠标事件


    覆盖物状态改变时触发的事件

    mousemove  mouseover  mouseout

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>map</title>
        <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=ce3b1a3a7e67fc75810ce1ba1f83c01a"></script> 
        <style>
            *{margin:0;padding:0;list-style: none;}
            #container {width:100%; height: 100%;top:0;left:0;position: absolute; }  
            #panel{position: fixed;width:280px;top:10px;right:10px;background-color: #fff;}
        </style>
    </head>
    <body>
        <div id="container"></div> 
        <div id="panel"></div>
    
        <script>
            var map=new AMap.Map("container",{
                zoom:11,
                center:[121.549792,29.868388],
                resizeEnable:true//不开启则无法触发resize事件
            });   
    
            var txt=new AMap.Text({
                text:"覆盖物事件",
                position:[121.549792,29.868388]
            }).on("mouseover",function(){
                console.log("覆盖物移入");
            }).on("mouseout",function(){
                console.log("覆盖物移出");
            }).on("mousemove",function(){
                console.log("覆盖物上移动中");
            })
    
            txt.setMap(map);
    
        </script>    
    </body>
    </html>

    show  hide

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>map</title>
        <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=ce3b1a3a7e67fc75810ce1ba1f83c01a"></script> 
        <style>
            *{margin:0;padding:0;list-style: none;}
            #container {width:100%; height: 100%;top:0;left:0;position: absolute; }  
            #panel{position: fixed;width:280px;top:10px;right:10px;background-color: #fff;}
        </style>
    </head>
    <body>
        <div id="container"></div> 
        <div id="panel"></div>
    
        <script>
            var map=new AMap.Map("container",{
                zoom:11,
                center:[121.549792,29.868388],
                resizeEnable:true//不开启则无法触发resize事件
            });   
    
            //矢量图--圆
            var circle=new AMap.Circle({
                center:[121.549792,29.868388],
                radius:1000
            })
    
            circle.setMap(map);
    
            //矢量图--方
            var rect=new AMap.Rectangle({
                bounds:new AMap.Bounds(new AMap.LngLat(121.549792,29.868388),new AMap.LngLat(121.569792,29.848388))
            })
    
            rect.setMap(map);
    
            setTimeout(function(){
                circle.hide();
            },2000)
            setTimeout(function(){
                rect.hide();
            },4000)
            setTimeout(function(){
                circle.show();
            },6000)
            setTimeout(function(){
                rect.show();
            },8000)
    
        </script>    
    </body>
    </html>

    open()  close()

    ContextMenu指的是右键

    map.zoomIn()  map.zoomOut()

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>map</title>
        <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=ce3b1a3a7e67fc75810ce1ba1f83c01a"></script> 
        <style>
            *{margin:0;padding:0;list-style: none;}
            #container {width:100%; height: 100%;top:0;left:0;position: absolute; }  
            #panel{position: fixed;width:280px;top:10px;right:10px;background-color: #fff;}
        </style>
    </head>
    <body>
        <div id="container"></div> 
        <div id="panel"></div>
    
        <script>
            var map=new AMap.Map("container",{
                zoom:11,
                center:[121.549792,29.868388],
                resizeEnable:true//不开启则无法触发resize事件
            });   
    
            var cm=new AMap.ContextMenu();
            cm.addItem("放大一级",function(){
                map.zoomIn();//放大一级map的级别
            },0)
            cm.addItem("缩小一级",function(){
                map.zoomOut();//缩小一级map的级别
            },1)
    
            map.on("rightclick",function(e){
                console.log(e.lnglat);
                cm.open(map,e.lnglat);
    
                //右键3秒后关闭
                setTimeout(function(){
                    cm.close();
                },3000)
            })
            
    
        </script>    
    </body>
    </html>

  • 相关阅读:
    Android事件分发
    Android 内存泄露
    Android IPC介绍
    Android垃圾回收机制
    (C#)为应用程式设定运行权限(System.Security类下的GenericIdentity,GenericPrincipal,PrincipalPermission)
    http请求
    VS 的链接库的设置
    在VS中添加lib库的三种方法
    二分法查找数组
    Remove Duplicates from Sorted Array II
  • 原文地址:https://www.cnblogs.com/chenyingying0/p/12436854.html
Copyright © 2020-2023  润新知