SuperMap iClient for Leaflet的基本使用

1、引入Leaflet

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.5.1/leaflet.css" />
<link rel="stylesheet" href="https://iclient.supermap.io/dist/leaflet/iclient-leaflet.min.css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.5.1/leaflet.js"></script>
<script type="text/javascript" src="https://iclient.supermap.io/dist/leaflet/iclient-leaflet.js"></script>

 

 

 2、初始化地图底图

 var map,url='https://iserver.supermap.io/iserver/services/map-china400/rest/maps/China';
map = L.map('map', {
                        center: [39.830660058696104, 116.92866163503169],
                        maxZoom: 18,
                        maxZoom:25,
                        minZoom:3,
                        zoom: 13 ,
                     crs:  L.CRS.EPSG3857,
                    })
                 
                    new L.supermap.tiledMapLayer(url).addTo(map);

渲染:

771b43b41b1a4d31b32c8132e3613d90.png 

3、标记点的渲染、图层的切换

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title data-i18n="resources.title_tiledMapLayer4326"></title>
    <link
      href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.css"
      rel="stylesheet"
    />
    <script
      type="text/javascript"
      src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.js"
    ></script>
    <script
      type="text/javascript"
      src="https://iclient.supermap.io/dist/leaflet/iclient-leaflet.js"
    ></script>
  </head>
  <style>
	.flex{
	position: relative;
	left: 5px;
	bottom: 50%;
    z-index: 999;
    background-color: skyblue;
    width: 70px;
	}
  </style>
  <body
    style="
      margin: 0;
      overflow: hidden;
      background: #fff;
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0;
    "
  >
    <div id="map" style="margin: 0 auto; width: 100%; height: 100%"></div>
	<!-- <button class="flex" >显示隐藏</button> -->
    <!-- <script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script> -->
    <script type="text/javascript">
		// 坐标点
      const iconMarker = new L.Icon({
        iconUrl:
          'https://cdn.jsdelivr.net/npm/leaflet@1.7.1/dist/images/marker-icon.png',
        shadowUrl:
          'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
        iconSize: [25, 41],
        iconAnchor: [12, 41],
        popupAnchor: [1, -34],
        shadowSize: [41, 41],
      })
	  var BJ = L.marker([39.830660058696104, 116.92866163503169]).bindPopup('This is Littleton, CO.'),
        CD = L.marker([30.40, 104.04]).bindPopup('This is Littleton, CO.'),
    dd=    L.marker([39.61, -105.02]).bindPopup('This is Littleton, CO.'),
    denver    = L.marker([39.74, -104.99]).bindPopup('This is Denver, CO.'),
    aurora    = L.marker([39.73, -104.8]).bindPopup('This is Aurora, CO.'),
    golden    = L.marker([39.77, -105.23]).bindPopup('This is Golden, CO.');
    var cities = L.layerGroup([BJ, CD,dd]);
    var baijin = L.layerGroup([BJ, golden]);
    var aurora = L.layerGroup([denver,aurora,golden]);
	  var url ="https://iserver.supermap.io";
var China = new L.supermap.TiledMapLayer(url + '/iserver/services/map-china400/rest/maps/China',{noWrap:true});
// var ChinaDark = new L.supermap.TiledMapLayer(url + '/iserver/services/map-china400/rest/maps/ChinaDark', {noWrap:true});
      var map = L.map('map', {
        center: [39.830660058696104, 116.92866163503169],
		maxZoom: 18,
        zoom: 5,
        crs: L.supermap.CRS.TianDiTu_Mercator,
		layers: [China, cities]
      })
	  var baseMaps = {
      "<span style='color: gray'>Grayscale</span>": China,
        // "ChinaDark": ChinaDark
    };
    var overlayMaps = {
        "Cities": cities,
        "北京": baijin,
        "北美洲": aurora
    };
    L.control.layers(baseMaps, overlayMaps).addTo(map);

L.marker([35.830660058696104, 116.92866163503169], {
        icon: iconMarker,
      })
        .addTo(map)
        .bindPopup('aaaaaaaaaaaaaaa')
        .openPopup()

	 


	
    </script>
  </body>
</html>

a98c6f842cef45da969775f0e97a71ff.png

 

4、实际应用,显示隐藏标记点

//前后端不分离项目  无法使用es6语法
 var miniFireStationIcon = new L.Icon({
   iconUrl:'/IFCS/ui/img/marker/miniFireStation.png',
  shadowUrl:'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
                        iconSize: [50, 71],
                        iconAnchor: [12, 41],
                        popupAnchor: [1, -34],
                        shadowSize: [41, 41],
                    })
          for (var index = 0; index < params.length; index++) {
        console.log(params[index].lat, params[index].lng)
        var qqq=   L.marker([params[index].lat, params[index].lng], {
            icon: miniFireStationIcon,
            opacity:1
        }).addTo(map).bindTooltip(params[index].ministationName,{
            offset: [15, -25],
            direction: "top"
        })
        qqq.on('click',function(e){
            console.log(e,'eeee')
            var aa=null
            $.each(params, function (index, item) {
                console.log(item)
                if(item.ministationName==e.target._tooltip._content){
                    aa=item
                }
            })
            map.panTo([ aa.lat,aa.lng]);//设置地图中心
              //给弹窗赋值
            $("#ministationName").html(e.target._tooltip._content);
            $("#gunNum").html(aa.gunNum);
            $("#hoseNum").html(aa.hoseNum);
            $("#fireExtinguisherNum").html(aa.fireExtinguisherNum);
            $("#fireClothingNum").html(aa.fireClothingNum);
            $("#firEhelmetNum").html(aa.firEhelmetNum);
            $("#fireBootsNum").html(aa.fireBootsNum);
            $("#domolitionToolsNum").html(aa.domolitionToolsNum);
            $("#minipumperNum").html(aa.minipumperNum);
            $(".info-modal").hide();
            $(".info-modal-miniFireStation").show()
        })
        markers.push(qqq)
    }

    $('#miniFireStationArr').on('click',function(e){
        console.log(e,'miniFireStationArr')
    markers.forEach(function (item) {

        if(e.target.attributes[0].nodeValue=='chooseMark'){
            map.removeLayer(item)//删除点位
        }else{
            map.addLayer(item)//添加点位
        }

    })
})

 

渲染:

   弹窗

ee384ea897324089a7780c72ef9dee45.png 

 

实例:ad33a49a73284a7094632f5157bca69a.png

 

 

 

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: SuperMap iClient for Leaflet是一款基于Leaflet框架的地图开发工具,可以帮助开发者快速构建WebGIS应用程序。它提供了丰富的地图功能和数据处理能力,支持多种数据格式和服务类型,可以轻松实现地图展示、数据查询、空间分析等功能。同时,它还具有良好的跨平台性和扩展性,可以在PC端、移动端和Web端等多种平台上使用。 ### 回答2: SuperMap iClient for Leaflet是一种基于JavaScript代码库的Web GIS开发产品,在Leaflet框架上构建出新一代的互联网GIS应用程序。SuperMap iClient for Leaflet可以在地图展示、查询分析、数据处理和空间计算等方面提供完整的功能支持,并且能够快速开发出高效、稳定和复杂的互联网GIS系统。 在SuperMap iClient for Leaflet中,Leaflet是作为主要的基础库来展示地图和功能的。Leaflet是一个轻量级的Web地图框架,具有高度的可定制性,并支持多种图层、地图的基本交互操作和协同显示。因此,SuperMap iClient for Leaflet可以和其他Web GIS开发库完美地协同工作。 SuperMap iClient for Leaflet的主要功能包括: 1.地图服务:可以快速地加载和显示多种切片和动态地图服务,支持图层控制、标注、信息窗口等操作。 2.查询和统计分析:能够实现多种查询、统计和分析操作,例如点选查询、矩形查询、属性查询、空间查询、缓冲区分析、距离测量、区域统计分析、热力图绘制等。 3.数据可视化和渲染:支持多种数据可视化和渲染技术,例如图表、标签、符号、颜色、透明度等,让数据更加生动和易于理解。 4.地理编码和路径分析:支持多种地理编码和路径分析算法,例如最短路、最优路径、网络分析、行驶路线规划等,可以应对多种实际应用场景。 5.数据处理和导出:提供多种数据处理和导出操作,例如数据格式转换、剪裁、裁剪、融合、导入、导出等,使得GIS数据的管理更加高效和灵活。 总之,SuperMap iClient for Leaflet是Web GIS开发的一种高效、灵活、全面的解决方案,可以让用户快速构建出令人称道的Web GIS系统,满足多样化的GIS需求。 ### 回答3: SuperMap iClient for Leaflet是基于Leaflet框架封装开发的一个功能强大、易用性高、可定制性强的WebGIS开发框架。SuperMap iClient for Leaflet为开发者提供了丰富的地图可视化和分析功能,轻松支持各类GIS业务系统的快速构建和发布,拥有完善的API,可方便地与其他WebGIS技术或框架相结合。 SuperMap iClient for Leaflet可以实现多种数据源的地图服务,包括矢量数据、切片数据、动态数据和三维数据等。同时,SuperMap iClient for Leaflet还支持丰富的地图功能,包括地图缩放、平移、旋转、地图标注、查询、空间分析、路径规划等。 SuperMap iClient for Leaflet还支持地图的分层和可交互性。这些都有助于开发者在WebGIS领域获得更多的自由度和灵活度。在云计算、大数据、物联网技术的带动下,SuperMap iClient for Leaflet已经成为WebGIS技术中不可或缺的一部分。 总之,SuperMap iClient for Leaflet是一款完美的WebGIS开发框架,具有易用性、高可定制性和丰富的功能,可以帮助开发者更快速、更高效地构建出具有广泛应用价值的GIS业务系统,满足社会生产和生活中对于空间分析、智能数据分析等多个领域的需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值