在laravel中未经授权的API Arcgis到谷歌地图

问题描述 投票:1回答:1

我是ArcGIS的新手,但我想了解它。所以我有一个问题。我想将API中的ArcGIS数据放入Google Map。我已经在Laravel 5.7和javascript中创建了它。但我得到了一个错误未经授权的错误,如下图所示

enter image description here

这是我在视图刀片laravel中的javascript:

 <div id="map">

  </div>
    <script>
      var map;
      const TILE_ORIGIN = [-20037508.34789244, 20037508.34789244];
      const ORIG_X = 1;
      const ORIG_Y = 0;
      const MAP_SIZE = 20037508.34789244 * 2;
      const MINX = 0;
      const MAXX = 1;
      const MINY = 2;
      const MAXY = 3;

      function getBoundingBox(x, y, zoom){
         tileSize = MAP_SIZE / Math.pow(2, zoom);
         minx = TILE_ORIGIN[ORIG_X] + x * tileSize;
         maxx = TILE_ORIGIN[ORIG_X] + (x+1) * tileSize;
         miny = TILE_ORIGIN[ORIG_Y] - (y+1) * tileSize;
         maxy = TILE_ORIGIN[ORIG_Y] - y * tileSize;

         bbox = [minx, miny, maxx, maxy];


        return bbox;
      }
      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: -6.160323, lng: 106.905114},
          zoom: 18
        });

        var imageMapType = new google.maps.ImageMapType({
        getTileUrl: function(coord, zoom) {
          resultBBox = getBoundingBox(coord.x, coord.y,  zoom);
          url = "http://xx.xx.x.xx/arcgis/services/Asset/AssetMAP_Mobile/MapServer/WmsServer?LAYERS=1,2,3,4,5&TILED=true&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image/png&SRS=EPSG:3857&BBOX="+resultBBox[MINX]+","+resultBBox[MINY]+","+resultBBox[MAXX]+","+resultBBox[MAXY]+"&WIDTH=256&HEIGHT=256" ; //API
          console.log(url);

              return url;

            },

                tileSize: new google.maps.Size(256, 256)
        });
        map.overlayMapTypes.push(imageMapType);
      }
    </script>
    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBu5nZKbeK-WHQ70oqOWo-_4VmwOwKP9YQ&callback=initMap"
    async defer></script>

错误是用于身份验证,我必须输入用户名和密码吗?但我不知道如何在代码中对用户名和密码进行身份验证。有人可以帮帮我吗?

javascript google-maps laravel-5 arcgis arcgis-server
1个回答
0
投票

您可以使用代理页面使用ESRI的API访问安全的休息服务:

信息:https://developers.arcgis.com/javascript/3/jshelp/ags_proxy.html

Github回购:https://github.com/Esri/resource-proxy

© www.soinside.com 2019 - 2024. All rights reserved.