arcgis api for js 4.x学习笔记(1)地图加载(Map、MapView、MapImageLayer、TileLayer)

<div id="viewDiv" style="width:300px;height:300px"></div>
//本文对应Api 4.6版本
require(["esri/Map",
        "esri/views/MapView",
        "esri/layers/TileLayer",
        "esri/layers/MapImageLayer",
        "esri/geometry/Extent",
        'dojo/domReady!'
    ],function (Map,MapView,TileLayer,MapImageLayer,Extent ) {
    var tileUrl = "http://localhost:6080/arcgis/rest/services/mapFile/tileMap/MapServer";
    var imageUrl = "http://localhost:6080/arcgis/rest/services/mapFile/imageMap/MapServer";
    var multiLayerImageUrl = "http://localhost:6080/arcgis/rest/services/mapFile/multiLayerImageMap/MapServer";
    var tileLayer = new TileLayer({
            url: tileUrl,
            visible:true
        });
    var imageLayer = new MapImageLayer({
            url: imageUrl ,
            visible:true
        });
    var multiImageLayer = new MapImageLayer({
            url: multiLayerImageUrl,
            sublayers: [//控制多个图层中图层显示或不显示。注意,id必须从大到小倒着写。
                {
                    id: 3,
                    visible: false
                },
                {
                    id: 2,
                    visible: true
                },
                {
                    id: 1,
                    visible: false
                },
                {
                    id: 0,
                    visible: true
                }
            ]
        });
     var map = new Map({
            layers:[tileLayer,imageLayer,multiImageLayer]//图层顺序tileLayer在最底层,multiImageLayer在最顶层
        });
     var view = new MapView({
            container: "viewDiv",
            map: map,
            center: [117.2300, 36.700], // longitude, latitude
        });
     //地图不旋转
     view.constraints={
            rotationEnabled:false
        };
     view.extent = new Extent({
            xmin: 116.989,
            ymin: 36.593,
            xmax: 117.177,
            ymax: 36.722,
            spatialReference: {
                wkid: 4490
            }
        });




})

附:各版本api包下载地址:https://pan.baidu.com/s/1nzw8aTfwpzD1m47Wr7rHEA  提取码:71vo 。 各版本中的sdk压缩包为在线api,找到index.html在浏览器中打开即可。

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值