0

I have my own custom service map. I have a base map, layers etc...

I need to use it instead of ArcGIS default basemaps and layers.

For now I trying this:

<!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">
 <link rel="stylesheet" href="https://js.arcgis.com/3.43/esri/css/esri.css">
 <script src="https://js.arcgis.com/3.43/"></script>
 <!-- <link rel="stylesheet" href="https://js.arcgis.com/3.22/esri/css/esri.css">
 <script src="https://js.arcgis.com/3.22compact/"></script> -->
 <style>
 html, body, #map {
 height: 100%;
 padding: 0;
 margin: 0;
 }
 </style>
 
 <title></title>
 </head>
 <body class="claro">
 
 <div id="map"></div>
 <script>
 var map;
 require(["esri/map",], function(Map) {
 const baseMapUrl = 'http.expample/MapaBase_1x/MapServer'
 map = new Map("map", {
 basemap: 'streets',
 center: [-122.45, 37.75],
 zoom: 13
 });
 });
 </script>
 </body>
</html>

The variable baseMapUrl is my custom map server URL, How can I use it with ArcGIS 3.43?

asked Mar 7, 2023 at 19:23
7
  • Please Edit the Question to clarify what you mean by "custom service". If you are using ArcGIS Server, please specify the actual version in use. Commented Mar 7, 2023 at 21:06
  • Hi @Vince, I mean is a server where we have our own map, layers, etc. This map is not from ArcGis server. I have two urls, one for basemap and another one for custom layer. Commented Mar 8, 2023 at 15:03
  • What map protocol does this server implement? If it isn't a protocol of which the JSAPI is aware, you'd need to write a proxy to wrap it into a functional protocol. Commented Mar 8, 2023 at 15:08
  • It's a REST server. Commented Mar 8, 2023 at 16:03
  • 1
    Hi @BPolanco, there are many different REST server protocols, including ArcGIS Server, WMS/WMTS and other OGC etc. Do you you know what specific format it is? Or can you share the URL? Is your server self-made or is it using a specific product? Knowing this well help understand how to consume it it. Also note that you are referencing the old legacy 3x version of the API. Unless it's an existing app, you should probably use version 4x. Commented Mar 8, 2023 at 18:27

1 Answer 1

0

Yes, you can use your own map service as the basemap instead of one of the out-of-box basemaps. The basic steps are

  1. create the layer,
  2. create a Basemap and set its "baseLayers" to the layer you created in step 1.
<html lang="en">
 <head>
 <meta charset="utf-8" />
 <meta
 name="viewport"
 content="initial-scale=1,maximum-scale=1,user-scalable=no"
 />
 <title>Custom Basemap | Sample | ArcGIS Maps SDK for JavaScript 4.26</title>
 <style>
 html,
 body,
 #viewDiv {
 padding: 0;
 margin: 0;
 height: 100%;
 width: 100%;
 }
 </style>
 <link
 href="https://js.arcgis.com/4.26/esri/themes/light/main.css"
 rel="stylesheet"
 type="text/css"
 />
 <script src="https://js.arcgis.com/4.26/"></script>
 <script>
 require([
 "esri/layers/MapImageLayer",
 "esri/layers/TileLayer",
 "esri/Map",
 "esri/Basemap",
 "esri/views/MapView"
 ], (MapImageLayer, TileLayer, Map, Basemap, MapView) => {
 const myBaseLayer = new TileLayer({
 url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer"
 });
 const myBasemap = new Basemap({
 baseLayers: [myBaseLayer]
 });
 const map = new Map({
 basemap: myBasemap
 });
 const view = new MapView({
 container: "viewDiv",
 map: map,
 zoom: 5,
 center: [-122.18, 37.49] // longitude, latitude
 });
 });
 </script>
 </head>
 <body>
 <div id="viewDiv"></div>
 </body>
</html>

See https://codepen.io/bsvensson/pen/rNZgKrr?editors=1000

Read more at https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html and https://developers.arcgis.com/javascript/latest/sample-code/

If your mapservice is not cached, you would use MapImageLayer instead of TileLayer.

answered Mar 31, 2023 at 1:14

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.