<?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: Get mapView in another Angular Component in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-mapview-in-another-angular-component/m-p/1118816#M75347</link>
    <description>&lt;P&gt;You can move all the JSAPI logic into an injectable service and use that service in components you want to be able to access it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import { Injectable } from '@angular/core';

import WebMap from '@arcgis/core/WebMap';
import MapView from '@arcgis/core/views/MapView';
import Bookmarks from '@arcgis/core/widgets/Bookmarks';
import Expand from '@arcgis/core/widgets/Expand';

@Injectable({
  providedIn: 'root'
})
export class MapService {
  public view: MapView | null = null;

  constructor() {}

  async createMap(container: HTMLDivElement) {
    const webmap = new WebMap({
      portalItem: {
        id: 'aa1d3f80270146208328cf66d022e09c'
      }
    });

    const view = new MapView({
      container,
      map: webmap
    });

    const bookmarks = new Bookmarks({
      view,
      // allows bookmarks to be added, edited, or deleted
      editingEnabled: true
    });

    const bkExpand = new Expand({
      view,
      content: bookmarks,
      expanded: true
    });

    // Add the widget to the top-right corner of the view
    view.ui.add(bkExpand, 'top-right');

    // bonus - how many bookmarks in the webmap?
    webmap.when(() =&amp;gt; {
      if (webmap.bookmarks &amp;amp;&amp;amp; webmap.bookmarks.length) {
        console.log('Bookmarks: ', webmap.bookmarks.length);
      } else {
        console.log('No bookmarks in this webmap.');
      }
    });

    this.view = view;
    return this.view.when();
  }
}&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 19 Nov 2021 19:09:30 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2021-11-19T19:09:30Z</dc:date>
    <item>
      <title>Get mapView in another Angular Component</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-mapview-in-another-angular-component/m-p/1118794#M75345</link>
      <description>&lt;P&gt;Hello! Let me explain better my issue:&amp;nbsp;&lt;BR /&gt;- I created (in a typical way) a map View in the angular "component One":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export class MapComponent implements OnInit, OnDestroy {
  view: any;
  
  @ViewChild('esriMap', { static: true }) private mapViewEl!: ElementRef;

  initializeMap(): Promise&amp;lt;any&amp;gt; {
    const container = this.mapViewEl.nativeElement;
    esriConfig.portalUrl = "....";
    const webmap = new WebMap({
      portalItem: {
        id: '...',
      },
    });

    const layer = new FeatureLayer({
      // URL to the service
      URL: "..."
    });

    webmap.add(layer)

    const view = new MapView({
      container,
      map: webmap,
      zoom: 3,
      constraints: {
        minZoom: 3
      }
    });

    this.view = view;
    return this.view.when();
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I need to use the "goTo" method in another angular component, let's call it "component Two".&amp;nbsp;&lt;BR /&gt;How can I access the view defined in the component One from the component Two? Is it possible?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you so much&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 18:23:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-mapview-in-another-angular-component/m-p/1118794#M75345</guid>
      <dc:creator>matteorizzi</dc:creator>
      <dc:date>2021-11-19T18:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Get mapView in another Angular Component</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-mapview-in-another-angular-component/m-p/1118816#M75347</link>
      <description>&lt;P&gt;You can move all the JSAPI logic into an injectable service and use that service in components you want to be able to access it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import { Injectable } from '@angular/core';

import WebMap from '@arcgis/core/WebMap';
import MapView from '@arcgis/core/views/MapView';
import Bookmarks from '@arcgis/core/widgets/Bookmarks';
import Expand from '@arcgis/core/widgets/Expand';

@Injectable({
  providedIn: 'root'
})
export class MapService {
  public view: MapView | null = null;

  constructor() {}

  async createMap(container: HTMLDivElement) {
    const webmap = new WebMap({
      portalItem: {
        id: 'aa1d3f80270146208328cf66d022e09c'
      }
    });

    const view = new MapView({
      container,
      map: webmap
    });

    const bookmarks = new Bookmarks({
      view,
      // allows bookmarks to be added, edited, or deleted
      editingEnabled: true
    });

    const bkExpand = new Expand({
      view,
      content: bookmarks,
      expanded: true
    });

    // Add the widget to the top-right corner of the view
    view.ui.add(bkExpand, 'top-right');

    // bonus - how many bookmarks in the webmap?
    webmap.when(() =&amp;gt; {
      if (webmap.bookmarks &amp;amp;&amp;amp; webmap.bookmarks.length) {
        console.log('Bookmarks: ', webmap.bookmarks.length);
      } else {
        console.log('No bookmarks in this webmap.');
      }
    });

    this.view = view;
    return this.view.when();
  }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 19 Nov 2021 19:09:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-mapview-in-another-angular-component/m-p/1118816#M75347</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-11-19T19:09:30Z</dc:date>
    </item>
  </channel>
</rss>

