Select to view content in your preferred language

Map View is so small

589
5
Jump to solution
11-15-2023 11:40 AM
DRae
by
Occasional Contributor

Hi I am new to React and ArcGIS. I tried to write some simple React web application to show the map. However the map is show so small inside the canvas. You can see the below code and attache screenshot

MY ScreenshotMY Screenshot

Spoiler
 
const webmap = new Map({
basemap: 'topo-vector'
})

mapRef.current = new MapView({
map: webmap,
container: "mapViewId",
});

viewRef.current = mapRef.current;

const view = viewRef.current;

view.when( () => {
console.log('mapview');
})
}

}, []);

return <div className="mapDiv" id="mapViewId" ></div>;
};

 css

Spoiler
.mapDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}

 

0 Kudos
1 Solution

Accepted Solutions
JeffreyThompson2
MVP Regular Contributor

Your map is actually taking up the entire page, but it is very zoomed out. Try specifying a center and a zoom level, something like this:

mapRef.current = new MapView({
   map: webmap,
   container: "mapViewId",
   center: [-118.805, 34.027], // Longitude, latitude
   zoom: 13 // Zoom level
});

 https://developers.arcgis.com/javascript/latest/tutorials/display-a-map/#create-a-map-view

GIS Developer
City of Arlington, Texas

View solution in original post

0 Kudos
5 Replies
Brian_Wilson
Honored Contributor

Try using

.mapDiv {
  height:400px;
  width:800px;
}
0 Kudos
DRae
by
Occasional Contributor

tried and it make is much small on my screen.

 

Screenshot 2023-11-15 at 2.54.22 PM.png

0 Kudos
KenBuja
MVP Esteemed Contributor

Normally when looking at the entire world, you're going to see a small map. For example, open this sample and zoom out as far as you can.

mapview.png

Set the MapView's zoom property (or extent) to a more localized view of map and it should fill up the screen.

0 Kudos
JeffreyThompson2
MVP Regular Contributor

Your map is actually taking up the entire page, but it is very zoomed out. Try specifying a center and a zoom level, something like this:

mapRef.current = new MapView({
   map: webmap,
   container: "mapViewId",
   center: [-118.805, 34.027], // Longitude, latitude
   zoom: 13 // Zoom level
});

 https://developers.arcgis.com/javascript/latest/tutorials/display-a-map/#create-a-map-view

GIS Developer
City of Arlington, Texas
0 Kudos
DRae
by
Occasional Contributor

Thank. after changing the zoom level, and it is looking good now.

0 Kudos