<?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 create a custom map in a multi-component Angular 18 app in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-a-custom-map-in-a-multi-component-angular/m-p/1573241#M86343</link>
    <description>&lt;P&gt;How can I add a new component to an Angular 18 app that incorporates a view of a map using the&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core library. I have given it my best shot, but cannot get the 'custom-map' component to visualize within &lt;A href="https://github.com/bds134/custom-arcgis-map-in-angular.git" target="_blank" rel="noopener"&gt;my github repo&lt;/A&gt;. Currently, the Angular app runs and all components can be visualized, even the 'map' component which uses the &amp;lt;arcgis-map&amp;gt; tag in the component's html&amp;nbsp; in order to show a web map. Yet the custom map component does not show up. Can anyone help? I am completely lost!&lt;/P&gt;&lt;P&gt;I assume that the git repo linked above is the place that you need to look, but in case it help, I am including here just the 'custom map' component typescript file. Thanks for any help you can offer.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import {
  Component,
  OnInit,
  ViewChild,
  ElementRef,
  OnDestroy,
} from '@angular/core';

import Map from "@arcgis/core/Map.js";
import * as locator from "@arcgis/core/rest/locator.js";
import MapView from '@arcgis/core/views/MapView';
import Search from '@arcgis/core/widgets/Search';

@Component({
  selector: 'app-custom-map',
  templateUrl: './custom-map.component.html',
  styleUrl: './custom-map.component.css'
})
export class CustomMapComponent implements OnInit, OnDestroy {
  public view: any = null;

  // The &amp;lt;div&amp;gt; where we will place the map
  @ViewChild('mapViewNode', { static: true }) private mapViewEl!: ElementRef;

  initializeMap(): Promise&amp;lt;any&amp;gt; {
    const container = this.mapViewEl.nativeElement;

    const map = new Map({
      basemap: "streets-navigation-vector"
    });

    this.view = new MapView({
      container,
      map: map,
      center: [-100, 23.5],
      zoom: 4
    });

  /*
    const searchWidget = new Search({
      view: this.view
    });

    searchWidget.on("select-result", function (event2) {
      const searchname = event2.result.name;
    });

    this.view.ui.add(searchWidget, 'bottom-left');

    const locatorUrl =
      "https://utility.arcgis.com/usrsvcs/servers/0f0fda27f9c4487792fdc992e1eef1e6/rest/services/World/GeocodeServer";

    this.view.popupEnabled = false;
    this.view.on("click", (event:any) =&amp;gt; {
      // Get the coordinates of the click on the view
      const lat = Math.round(event.mapPoint.latitude * 1000000) / 1000000;
      const lon = Math.round(event.mapPoint.longitude * 1000000) / 1000000;

      this.view.openPopup({
        // Set the popup's title to the coordinates of the location
        content: lat + ", " + lon + "&amp;lt;br&amp;gt;&amp;lt;i&amp;gt;&amp;lt;span style='font-size:smaller'&amp;gt;&amp;amp;nbsp&amp;amp;nbspe.g. 'latitude, longitude'&amp;lt;p&amp;gt;NB: lat/lon values do not automatically transfer into form boxes above. You must do so manually.",
        location: event.mapPoint // Set the location of the popup to the clicked location
      });

      const params = {
        location: event.mapPoint
      };

      // Display the popup
      // Execute a reverse geocode using the clicked location
      locator
        .locationToAddress(locatorUrl, params)
        .then((response) =&amp;gt; {
          // If an address is successfully found, show it in the popup's content
          this.view.popup.title = response.address;
          const placename = response.address;
        })
        .catch(() =&amp;gt; {
          // If the promise fails and no result is found, show a generic message
          this.view.popup.content = "No address was found for this location";
        });

    });
*/
    return this.view.when();
  }

  ngOnInit(): any {
    // Initialize MapView and return an instance of MapView
    this.initializeMap().then(() =&amp;gt; {
      // The map has been initialized
      console.log('The map is ready.');
    });
  }

  ngOnDestroy(): void {
    if (this.view) {
      // destroy the map view
      this.view.destroy();
    }
  }
}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jan 2025 17:30:06 GMT</pubDate>
    <dc:creator>BradSkopyk</dc:creator>
    <dc:date>2025-01-07T17:30:06Z</dc:date>
    <item>
      <title>create a custom map in a multi-component Angular 18 app</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-a-custom-map-in-a-multi-component-angular/m-p/1573241#M86343</link>
      <description>&lt;P&gt;How can I add a new component to an Angular 18 app that incorporates a view of a map using the&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core library. I have given it my best shot, but cannot get the 'custom-map' component to visualize within &lt;A href="https://github.com/bds134/custom-arcgis-map-in-angular.git" target="_blank" rel="noopener"&gt;my github repo&lt;/A&gt;. Currently, the Angular app runs and all components can be visualized, even the 'map' component which uses the &amp;lt;arcgis-map&amp;gt; tag in the component's html&amp;nbsp; in order to show a web map. Yet the custom map component does not show up. Can anyone help? I am completely lost!&lt;/P&gt;&lt;P&gt;I assume that the git repo linked above is the place that you need to look, but in case it help, I am including here just the 'custom map' component typescript file. Thanks for any help you can offer.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import {
  Component,
  OnInit,
  ViewChild,
  ElementRef,
  OnDestroy,
} from '@angular/core';

import Map from "@arcgis/core/Map.js";
import * as locator from "@arcgis/core/rest/locator.js";
import MapView from '@arcgis/core/views/MapView';
import Search from '@arcgis/core/widgets/Search';

@Component({
  selector: 'app-custom-map',
  templateUrl: './custom-map.component.html',
  styleUrl: './custom-map.component.css'
})
export class CustomMapComponent implements OnInit, OnDestroy {
  public view: any = null;

  // The &amp;lt;div&amp;gt; where we will place the map
  @ViewChild('mapViewNode', { static: true }) private mapViewEl!: ElementRef;

  initializeMap(): Promise&amp;lt;any&amp;gt; {
    const container = this.mapViewEl.nativeElement;

    const map = new Map({
      basemap: "streets-navigation-vector"
    });

    this.view = new MapView({
      container,
      map: map,
      center: [-100, 23.5],
      zoom: 4
    });

  /*
    const searchWidget = new Search({
      view: this.view
    });

    searchWidget.on("select-result", function (event2) {
      const searchname = event2.result.name;
    });

    this.view.ui.add(searchWidget, 'bottom-left');

    const locatorUrl =
      "https://utility.arcgis.com/usrsvcs/servers/0f0fda27f9c4487792fdc992e1eef1e6/rest/services/World/GeocodeServer";

    this.view.popupEnabled = false;
    this.view.on("click", (event:any) =&amp;gt; {
      // Get the coordinates of the click on the view
      const lat = Math.round(event.mapPoint.latitude * 1000000) / 1000000;
      const lon = Math.round(event.mapPoint.longitude * 1000000) / 1000000;

      this.view.openPopup({
        // Set the popup's title to the coordinates of the location
        content: lat + ", " + lon + "&amp;lt;br&amp;gt;&amp;lt;i&amp;gt;&amp;lt;span style='font-size:smaller'&amp;gt;&amp;amp;nbsp&amp;amp;nbspe.g. 'latitude, longitude'&amp;lt;p&amp;gt;NB: lat/lon values do not automatically transfer into form boxes above. You must do so manually.",
        location: event.mapPoint // Set the location of the popup to the clicked location
      });

      const params = {
        location: event.mapPoint
      };

      // Display the popup
      // Execute a reverse geocode using the clicked location
      locator
        .locationToAddress(locatorUrl, params)
        .then((response) =&amp;gt; {
          // If an address is successfully found, show it in the popup's content
          this.view.popup.title = response.address;
          const placename = response.address;
        })
        .catch(() =&amp;gt; {
          // If the promise fails and no result is found, show a generic message
          this.view.popup.content = "No address was found for this location";
        });

    });
*/
    return this.view.when();
  }

  ngOnInit(): any {
    // Initialize MapView and return an instance of MapView
    this.initializeMap().then(() =&amp;gt; {
      // The map has been initialized
      console.log('The map is ready.');
    });
  }

  ngOnDestroy(): void {
    if (this.view) {
      // destroy the map view
      this.view.destroy();
    }
  }
}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2025 17:30:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-a-custom-map-in-a-multi-component-angular/m-p/1573241#M86343</guid>
      <dc:creator>BradSkopyk</dc:creator>
      <dc:date>2025-01-07T17:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: create a custom map in a multi-component Angular 18 app</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-a-custom-map-in-a-multi-component-angular/m-p/1588468#M86559</link>
      <description>&lt;P&gt;please consider the following code. have a test and share your feedback.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;import { Component, OnInit, ViewChild, ElementRef, OnDestroy } from '@angular/core';
import Map from "@arcgis/core/Map";
import MapView from "@arcgis/core/views/MapView";
import * as locator from "@arcgis/core/rest/locator";
import Search from '@arcgis/core/widgets/Search';

@Component({
  selector: 'app-custom-map',
  templateUrl: './custom-map.component.html',
  styleUrls: ['./custom-map.component.css']
})
export class CustomMapComponent implements OnInit, OnDestroy {
  public view: any = null;

  // The &amp;lt;div&amp;gt; where we will place the map
  @ViewChild('mapViewNode', { static: true }) private mapViewEl!: ElementRef;

  initializeMap(): Promise&amp;lt;any&amp;gt; {
    const container = this.mapViewEl.nativeElement;

    const map = new Map({
      basemap: "streets-navigation-vector"
    });

    this.view = new MapView({
      container,
      map: map,
      center: [-100, 23.5],
      zoom: 4
    });

    // Optional: Add a Search widget to the map
    const searchWidget = new Search({
      view: this.view
    });

    this.view.ui.add(searchWidget, 'top-left');

    return this.view.when();
  }

  ngOnInit(): void {
    this.initializeMap()
      .then(() =&amp;gt; {
        console.log('The map is ready.');
      })
      .catch((error) =&amp;gt; {
        console.error('Error initializing map:', error);
      });
  }

  ngOnDestroy(): void {
    if (this.view) {
      this.view.destroy();
    }
  }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 24 Feb 2025 11:30:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-a-custom-map-in-a-multi-component-angular/m-p/1588468#M86559</guid>
      <dc:creator>nafizpervez</dc:creator>
      <dc:date>2025-02-24T11:30:49Z</dc:date>
    </item>
  </channel>
</rss>

