Pallavi
Pallavi

Reputation: 9

How to disable map in arcgis javascript

I am new to arcgis javascript. I have created street map in arcgis javascript and also added graphics into that map.I want to disable that map not the graphics on that map.How can I do it?

Example-

I have added a basemap which has type of street and after that I am adding graphics i.e. line. Now, I want to disable street basemap .I want to show only lines.

Is it possible in arcgis javascript?

Upvotes: 0

Views: 1144

Answers (3)

Vikash Pandey
Vikash Pandey

Reputation: 5443

Well, Its clear that you want to hide the existing basemap from map after adding the line symbol/feature to the map.

It totally depends on how you have added your basemap. Below are two different approaches to achieve this-

1. Basemap is added as tiled map service.

if you have added basemap as ArcGISTiledMapServiceLayer the while adding give an ID or assign in varibale and use hide() method once you are done with your line graphics

For more details click here...

2. Basemap is added using only key of basemap

ArcGIS JS API also allows user to add few default basemap using only their keys. click here to know the keys/Name of the default basemaps.

However if you are using the second approach then first access the basemap layer object in map and once you find out the basemap then simply hide that using hide() method of the layer.

Feel free to shoot your queries.

Hoping this will help you :)

Upvotes: 0

LMokrane
LMokrane

Reputation: 826

or you could just add your layer of lines, without a basemap, ie :

require([
  "esri/map", "esri/layers/FeatureLayer",
  "esri/geometry/Extent", "esri/SpatialReference",
  "dojo/domReady!"], function(
    Map,  FeatureLayer,
    Extent, SpatialReference
  ) {
  var map = new Map("mapDiv", {extent: new Extent(-178.217598382, 18.921786345999976, -66.96927110500002, 71.40623554799998,new SpatialReference({ wkid:4326 }))});
  var statesLayer = new FeatureLayer('http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/2',
    {outFields: ["*"]}
  );
  map.addLayer(statesLayer);
});

Upvotes: 0

Reza
Reza

Reputation: 65

What you need to do is create your own custom basemap using(It would be a blank/empty service) Then you would need to add that new basemap to the gallery widget

https://developers.arcgis.com/javascript/3/jsapi/basemaplayer-amd.html

https://developers.arcgis.com/javascript/3/jsapi/basemapgallery-amd.html

If you didn't want to use the basemap gallery you can also utilize the newly created basemapLayer with the setBasemap. ie: map.setBasemap(emptybasemap);

Upvotes: 0

Related Questions