15

WebGis开发问题

arcgis_js_api的init.js和dojo/dojo.js的baseURL都改好了,IIS也部署好了

在代码中引用的下面这两个都能打开

<link
        rel="stylesheet"
        href="http://localhost/arcgis_js_api/library/4.17/esri/themes/light/main.css" />
    <script src="http://localhost/arcgis_js_api/library/4.17/dojo/dojo.js"></script>

main.css

dojo/dojo.js

 

 但是到我的一个Demo代码里就是没有效果

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="WebGisText1.WebForm4" %>
 
<!DOCTYPE html>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta
        name="viewport"
        content="initial-scale=1,maximum-scale=1,user-scalable=no" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <style>
        html,
        body,
        #viewDiv {
            padding: 0;
            margin: 0;
            height: 100%;
            width: 100%;
        }
    </style>
 
    <link
        rel="stylesheet"
        href="http://localhost/arcgis_js_api/library/4.17/esri/themes/light/main.css" />
    <script src="http://localhost/arcgis_js_api/library/4.17/dojo/dojo.js"></script>
    <script>
        require([
            "esri/Map",
            "esri/views/MapView",
        ], function (Map, MapView) {
            var map = new Map({
                basemap: "topo-vector"
            });
 
            var view = new MapView({
                container: "viewDiv",
                map: map,
                zoom: 4,
                center: [15, 65] // longitude, latitude
            });
        });
    </script>
</head>
<body>
    <div id="viewDiv"></div>
</body>
</html>

但是改为这样就有用

<link
        rel="stylesheet"
        href="http://localhost/arcgis_js_api/library/4.17/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.17/dojo/dojo.js"></script>
下面是改后源代码和效图:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="WebGisText1.WebForm4" %>
 
<!DOCTYPE html>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta
        name="viewport"
        content="initial-scale=1,maximum-scale=1,user-scalable=no" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <style>
        html,
        body,
        #viewDiv {
            padding: 0;
            margin: 0;
            height: 100%;
            width: 100%;
        }
    </style>
 
    <link
        rel="stylesheet"
        href="http://localhost/arcgis_js_api/library/4.17/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.17/dojo/dojo.js"></script>
    <script>
        require([
            "esri/Map",
            "esri/views/MapView",
        ], function (Map, MapView) {
            var map = new Map({
                basemap: "topo-vector"
            });
 
            var view = new MapView({
                container: "viewDiv",
                map: map,
                zoom: 4,
                center: [15, 65] // longitude, latitude
            });
        });
    </script>
</head>
<body>
    <div id="viewDiv"></div>
</body>
</html>

查看全部
Mr_Hamster
Mr_Hamster
2020/12/04 17:47
  • c#
  • chrome
  • asp.net
  • javascript
  • visual studio
  • 点赞
  • 收藏
  • 回答
    私信

0个回复