<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Restrict web map navigation extent in Enterprise 10.9.1 or Experience Builder Developer 1.12 in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/restrict-web-map-navigation-extent-in-enterprise/m-p/1353012#M6834</link>
    <description>&lt;P&gt;There are two approaches:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;In ArcGIS Pro, publish the web map setting a &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/layouts/customizing-your-map-extent.htm#:~:text=Map%20frame%20constraints%20allow%20you,on%20a%20different%20map%20frame." target="_self"&gt;Map frame constraint&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;In ExB Dev there is a &lt;A href="https://developers.arcgis.com/experience-builder/sample-code/widgets/map-view/" target="_self"&gt;custom 'map-view' widget i&lt;/A&gt;n the &lt;A href="https://github.com/Esri/arcgis-experience-builder-sdk-resources/tree/master" target="_self"&gt;Sample Code repository&lt;/A&gt;. With the ArcGIS API for JavaScript you can modify the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#when" target="_self"&gt;map view&lt;/A&gt; property (&lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-keep-the-view-over-a-specific-area-e-g-over/m-p/51843#M4545" target="_self"&gt;code example&lt;/A&gt;) to the intial default extent of the web map and set a minZoomScale property.&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;This video provides a great demo:&amp;nbsp;&lt;A href="https://www.youtube.com/watch?v=aVjtFKkF9q8" target="_blank"&gt;https://www.youtube.com/watch?v=aVjtFKkF9q8&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jan 2024 20:41:48 GMT</pubDate>
    <dc:creator>Yuriko</dc:creator>
    <dc:date>2024-01-15T20:41:48Z</dc:date>
    <item>
      <title>Restrict web map navigation extent in Enterprise 10.9.1 or Experience Builder Developer 1.13</title>
      <link>https://community.esri.com/t5/developers-questions/restrict-web-map-navigation-extent-in-enterprise/m-p/1350906#M6831</link>
      <description>&lt;P&gt;I understand we can restrict a web map's navigation extent as a&amp;nbsp;&lt;A href="https://support.esri.com/en-us/knowledge-base/how-to-limit-the-zoom-extent-of-a-web-map-shared-via-an-000024890#:~:text=On%20the%20Configure%20Navigation%20Boundary,Click%20Confirm." target="_self"&gt;configurable option in ArcGIS Online&lt;/A&gt;, but there aren't any such options in Enterprise 10.9.1 with which I'm working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any direction on how I might achieve&amp;nbsp;restricting the pan and zoom options within my Experience Builder Developer (v1.13) app to the area of interest?&lt;/P&gt;&lt;P&gt;Many thanks in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 20:44:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/restrict-web-map-navigation-extent-in-enterprise/m-p/1350906#M6831</guid>
      <dc:creator>Yuriko</dc:creator>
      <dc:date>2024-01-15T20:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: Restrict web map navigation extent in Enterprise 10.9.1 or Experience Builder Developer 1.12</title>
      <link>https://community.esri.com/t5/developers-questions/restrict-web-map-navigation-extent-in-enterprise/m-p/1353012#M6834</link>
      <description>&lt;P&gt;There are two approaches:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;In ArcGIS Pro, publish the web map setting a &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/layouts/customizing-your-map-extent.htm#:~:text=Map%20frame%20constraints%20allow%20you,on%20a%20different%20map%20frame." target="_self"&gt;Map frame constraint&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;In ExB Dev there is a &lt;A href="https://developers.arcgis.com/experience-builder/sample-code/widgets/map-view/" target="_self"&gt;custom 'map-view' widget i&lt;/A&gt;n the &lt;A href="https://github.com/Esri/arcgis-experience-builder-sdk-resources/tree/master" target="_self"&gt;Sample Code repository&lt;/A&gt;. With the ArcGIS API for JavaScript you can modify the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#when" target="_self"&gt;map view&lt;/A&gt; property (&lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-keep-the-view-over-a-specific-area-e-g-over/m-p/51843#M4545" target="_self"&gt;code example&lt;/A&gt;) to the intial default extent of the web map and set a minZoomScale property.&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;This video provides a great demo:&amp;nbsp;&lt;A href="https://www.youtube.com/watch?v=aVjtFKkF9q8" target="_blank"&gt;https://www.youtube.com/watch?v=aVjtFKkF9q8&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 20:41:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/restrict-web-map-navigation-extent-in-enterprise/m-p/1353012#M6834</guid>
      <dc:creator>Yuriko</dc:creator>
      <dc:date>2024-01-15T20:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: Restrict web map navigation extent in Enterprise 10.9.1 or Experience Builder Developer 1.12</title>
      <link>https://community.esri.com/t5/developers-questions/restrict-web-map-navigation-extent-in-enterprise/m-p/1360967#M6866</link>
      <description>&lt;P&gt;ExB Dev 1.13. Here is the widget.tsx code for a custom widget that restricts the map view&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;/**
  Licensing
  Copyright 2022 Esri
  Modified from 'map-view' sample code widget (JR, YH)

  Map view widget that will restrict the map view to the minZoomScale specified and restrict panning to the original extent of the map
*/
import { React, jimuHistory, DataSourceComponent, type AllWidgetProps, type IMState, type IMUrlParameters } from 'jimu-core'
import MapView from 'esri/views/MapView'
import type WebMap from 'esri/WebMap'
import Extent from 'esri/geometry/Extent'
import Point from "@arcgis/core/geometry/Point.js";
import { MapViewManager, type WebMapDataSource } from 'jimu-arcgis'
// Bring the 'Home' and 'Scalebar' properties into the map
import Home from '@arcgis/core/widgets/Home';
import ScaleBar from '@arcgis/core/widgets/ScaleBar';
import Popup from "@arcgis/core/widgets/Popup.js";


// Alert component state
interface State {
  isValidCenter: boolean;
}

// Not sure what the following does from the sample 'map-view' widget from which this code was modified queries the URL REST parameters for a mapview extent
interface ExtraProps {
  queryObject: IMUrlParameters
}

// Set a minimum zoom scale to prevent user from zooming out beyond the valid extent
const minZoomScale = 6


export default class Widget extends React.PureComponent&amp;lt;AllWidgetProps&amp;lt;unknown&amp;gt; &amp;amp; ExtraProps, State&amp;gt; {
  mapContainer = React.createRef&amp;lt;HTMLDivElement&amp;gt;()
  mapView: MapView
  webMap: WebMap
  extentWatch: __esri.WatchHandle

  mvManager: MapViewManager = MapViewManager.getInstance();

  constructor(props) {
    super(props);
    this.state = {
      isValidCenter: true, // Initialize state with default value
    };
  }

  static mapExtraStateProps = (state: IMState): ExtraProps =&amp;gt; {
    return {
      queryObject: state.queryObject
    }
  }

  onDsCreated = (webmapDs: WebMapDataSource) =&amp;gt; {
    console.log("Webmap loaded")
    if (!webmapDs) {
      console.log("Webmap not initialized")
      return
    }

    if (!this.mvManager.getJimuMapViewById(this.props.id)) {
      const options: __esri.MapViewProperties = {
        map: webmapDs.map,
        container: this.mapContainer.current,
        constraints:{
          minZoom: minZoomScale,
          snapToZoom: false
        }
        
      }
      console.log("minZoom set:", minZoomScale)

      this.mvManager.createJimuMapView({
        mapWidgetId: this.props.id,
        view: new MapView(options),
        dataSourceId: webmapDs.id,
        isActive: true,
        mapViewManager: this.mvManager
      }).then(jimuMapView =&amp;gt; {

        // Create and add the Home widget to the map view
        const homeWidget = new Home({ view: jimuMapView.view });
        jimuMapView.view.ui.add(homeWidget, 'top-left');
        
        // Need to explictly cast the view to --esri.MapViewProperties
        // to ensure type compatibility with the scalebar  
        const mapView = jimuMapView.view as __esri.MapViewProperties;
        // Create and add the Scalebar widget to the map view
        const scaleBarWidget = new ScaleBar({ view: mapView });
        jimuMapView.view.ui.add(scaleBarWidget,'bottom-left')
        
        //console.log(mapView.extent)
        const view = jimuMapView.view as __esri.MapView;
        const extentLimit = view.extent.clone();
        view.constraints.geometry = extentLimit

      })
    }
  }

  mapNode = &amp;lt;div className="widget-map" style={{ width: '100%', height: '100%' }} ref={this.mapContainer}&amp;gt;&amp;lt;/div&amp;gt;
  
  render () {
    if (!this.props.useDataSources || this.props.useDataSources.length === 0) {
      return 'Select a webmap in the settings panel'
    }
    return &amp;lt;DataSourceComponent useDataSource={this.props.useDataSources[0]} onDataSourceCreated={this.onDsCreated}&amp;gt;
      {this.mapNode}

    &amp;lt;/DataSourceComponent&amp;gt;
  }
}&lt;/LI-CODE&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 15 Jan 2024 20:44:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/restrict-web-map-navigation-extent-in-enterprise/m-p/1360967#M6866</guid>
      <dc:creator>Yuriko</dc:creator>
      <dc:date>2024-01-15T20:44:05Z</dc:date>
    </item>
  </channel>
</rss>

