This is a very simple question but a Google search did not provide an answer.
Basically suppose you have a map of the U.S. with states and county layers, as well as other layers like roads, etc.
I want to work with a map of only one state. in Arcgis JavaScript.
I did below code for whole world map loading:
var map;
require([
"esri/map",
"dojo/domReady!"
], function (
Map
) {
map = new Map("map", {
basemap: "osm",
center: [-122.9007, 47.0379],
zoom: 9
});
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>FeatureLayer - 4.3</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.3/esri/css/main.css">
<script src="https://js.arcgis.com/4.3/"></script>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/FeatureLayer",
"dojo/domReady!"
],
function(
Map, MapView,
FeatureLayer
) {
var map = new Map({
basemap: "hybrid"
});
var view = new MapView({
container: "viewDiv",
map: map,
center: [-120.007, 47.0379],
zoom: 7
});
/********************
* Add feature layer
********************/
// Carbon storage of trees in Warren Wilson College.
var featureLayer = new FeatureLayer({
url: "https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_States_Generalized/FeatureServ...",
outFields: ["*"],
definitionExpression: "STATE_NAME = 'Washington'"
});
map.add(featureLayer);
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
sethlewistempe Something is missing, It loading empty screen
JS Bin - Collaborative JavaScript Debugging
Does the jsbin link above render for you?
Is there any way to show only one state on screen,
The code provided shows only one state based on a definition expression.
above code highlights one state and loads total map. I'm looking for to show only one state on screen
above code looks as in image
JS Bin - Collaborative JavaScript Debugging
Changing the basemap property from "hybrid" to "satellilte" should provide what you're looking for.