ArcGIS API For Javascript之地图基本加载与显示,地图切换、缩放、定位、比例尺、鹰眼图、坐标显示、查询搜索功能实现

在前面的各项安装配置完成后,开始进行ArcGIS API for Javascript网页地图制作。

首先利用Html+Javascript前端编程实现底层地图加载显示,地图切换、缩放、定位、比例尺、鹰眼图、坐标显示、查询搜索功能实现。

代码:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
    <title>final Map</title>
    <link rel="stylesheet" href="http://localhost/arcgis_js_v314_api/arcgis_js_api/library/3.14/3.14/esri/css/esri.css">

    <style>
        html, body, #map {
            height: 100%;
            margin: 0;
            padding: 0;
        }

        body {
            background-color: #FFF;
            overflow: hidden;
            font-family: "Trebuchet MS";
        }

        #BasemapToggle {
            position: absolute;
            right: 20px;
            top: 20px;
            z-index: 50;
        }

        #HomeButton {
            left: 25px;
            position: absolute;
            top: 93px;
            z-index: 50;
        }

        #LocateButton {
            left: 25px;
            position: absolute;
            top: 130px;
            z-index: 50;
        }

        #search {
            display: block;
            position: absolute;
            z-index: 2;
            top: 25px;
            left: 75px;
        }
    </style>
    <script src=&#
  • 11
    点赞
  • 83
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
以下是一个示例代码,可以在 ArcGIS API for JavaScript显示页眉和地图区域,并将地图显示地图区域中: ```html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"> <title>ArcGIS JavaScript API - Simple Map</title> <link rel="stylesheet" href="https://js.arcgis.com/4.14/esri/themes/light/main.css"> <script src="https://js.arcgis.com/4.14/"></script> <style> html, body { padding: 0; margin: 0; height: 100%; width: 100%; } #mapViewDiv { height: calc(100% - 50px); width: 100%; } #header { height: 50px; width: 100%; background-color: #222; color: #fff; font-size: 24px; display: flex; align-items: center; justify-content: center; } </style> </head> <body> <div id="header">My Map</div> <div id="mapViewDiv"></div> <script> require([ "esri/Map", "esri/views/MapView" ], function (Map, MapView) { var map = new Map({ basemap: "streets-navigation-vector" }); var view = new MapView({ container: "mapViewDiv", map: map, center: [-118.244, 34.052], zoom: 10 }); }); </script> </body> </html> ``` 在这个示例中,我们使用了一个 div 元素来显示页眉,并设置了一个名为 "header" 的 ID。我们还使用另一个 div 元素来显示地图,并设置了一个名为 "mapViewDiv" 的 ID。在 CSS 样式表中,我们设置了这两个 div 元素的高度和宽度,以便它们占用整个页面空间。 在 JavaScript 代码中,我们加载了 "Map" 和 "MapView" 模块,然后创建了一个名为 "map" 的 Map 对象,使用 "streets-navigation-vector" 底,并将其传递给 "MapView" 的构造函数。我们还设置了 "MapView" 的 container 属性为 "mapViewDiv",以便地图显示在正确的 div 元素中。 最后,我们将 "MapView" 对象添加到页面中,并将地图中心设置为洛杉矶,并将缩放级别设置为 10。 这是一个简单的示例,您可以根据需要进行修改和扩展,以创建自己的定制地图应用程序。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值