-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular5 + CLI + API 3.23 Module not found: #95
Comments
@dimpyvirk may I ask why you are trying to |
@dimpyvirk As an example of the pattern @tomwayson is referring to you might want to check out this repo: https://github.com/Esri/angular-cli-esri-map |
@tomwayson I have an existing code using angular 2, API 3.18 and webpack. It is working fine with import. createAvlMap(domNodeOrId: any) { let mp = new Map(domNodeOrId, this.mapOptions); let baseObj = { id: '1', title: 'Base Map' }; let roadsObj = { id: '2', title: 'Roads' }; let labelRoadsObj = { id: '3', title: 'Label Roads' }; let facilityObj = { id: '4', title: 'Facility Area Labels' }; let landmarksObj = { id: '5', title: 'Landmarks', slider: true }; mp.addLayers([base, roads, labelRoads, facilty, landmarks]); this.esriMap = mp; Similarly for other functions related to maps import ArcGISTiledMapServiceLayer = require('esri/layers/ArcGISTiledMapServiceLayer'); createImageryLayer() { |
@dimpyvirk here's an working 3.23 sample of what @tomwayson was saying and based on
|
I'm guessing that it's either using a special configuration of webpack or a system-js library like esri-system-js, right? esri-loader is an alternative to those, which has many benefits, but one of the drawbacks is that you cannot use |
@dimpyvirk I'm going to go ahead and close this out...if you have addt'l issues please feel free to reopen. |
Hi @andygup and @tomwayson ! Some contextual background: Our Ionic Angular application is also currently on API 3.x and pretty much has the special configuration that @tomwayson described in the above comment. I am working on moving the app to Ionic 4 which uses the Angular CLI instead of Ionic's custom toolchain. This move from custom config for Angular to the CLI for the 3.x API is very similar to the OP's situation. I am trying to avoid ejecting from the CLI and customizing the webpack config. Because of this, moving to Questions: In the 3.x example provided above, how do you get TypeScript's type-checking without importing types and not having the special Thanks a lot for helping those of us using modern JS frameworks integrate with the JS SDK! 😃 Kevin |
I have no idea how to use 3.x types. Maybe #119 could work??? |
Thanks for the response and suggestion, @tomwayson . 🙂 I've attempted using the TS type importing referred to in #119 but was still getting build errors about not being able to resolve the esri modules being referenced. I may very well have had something not configured correctly, however. Since the technique may not yet be proven for use with the esri JS SDK, I was thinking the path of least resistance to get types in 3.x working was to do it the way it's currently recommended and known to work today. @andygup , is there a more complete example available for 3.x with the Angular CLI that has types working? It would be greatly valued if there was. 😀 Thank you so much! Kevin |
Thanks for trying. As far as I know, a 3.x types esri-loader example is like Sasquatch, many people claim to have seen it, but there is no concrete evidence of it's existence. |
@KevinKelchen I dug around and couldn't find any 3.x types example(s) either. ...like Sasquatch 😄 For your question about the code pattern snippet above that snippet is for 4.x and doesn't use any types or type checking. I know you aren't using 4.x, but here's an old 4.x types example + Angular: Esri/angular-cli-esri-map@e4a64b3#diff-2b32220f520753a373615d05469e578dR16 Also note, AFAIK Angular 6 doesn't officially support webpack eject, so esri-loader is still the preferred approach for Angular 6. CLI 7 just released a week ago and I haven't had a chance to verify it. Reference: angular/angular-cli#10618 |
Thank you, @tomwayson and @andygup ! @andygup, I appreciate you taking the time to search for examples! 😃 I, too, learned that the CLI doesn't support ejecting ATM. However, I did see some workaround and "hacky" solutions that allow customizing the webpack config without ejecting... To be clear about the Sasquatch specifics (😛), is it specifically 3.x types with the Angular CLI that don't exist? If so, what about Angular apps that don't use the CLI? Also, is the Sasquatch referring specifically to the use of Thank you! Kevin |
You can definitely use the ArcGIS JS API 3.x types with Angular 2+. It's just that there aren't any samples demonstrating the use of those types with
Same comment. The Angular component structure is the same whether you manually create components or use the CLI. CLI is just significantly faster than creating components by hand. |
That is exactly what I meant. Regardless of Angular, I'm not aware of any examples of esri-loader w/ the 3.x types (in React, or whateves). There were many conversations that lead me to believe that it was theoretically possible, maybe even others claiming they'd done it. That's why I left that cagily worded bit in the README about 3.x b/c I didn't want to discourage people if it was possible. I guess, like Sasquatch, I just really wanted to believe. At this point I think we should update README to say this probably won't work w/ 3.x types, |
Now, I'm going to put my hat on - aren't types optional? |
Thanks again, @andygup and @tomwayson ! That all makes sense. Thanks for your prompt replies and for taking the time to help me! I agree it's not a functional requirement to have type-checking for the JS SDK; it will definitely still work at runtime. As an Ionic/Angular/TypeScript user I really value having the types available for compile-time safety and intellisense. I recognize that the degree to which I value something may differ from that of others. 🙂 I will give Thanks again! Kevin |
Also, the 3.x types don't export the interfaces that you would typically expect, it's things like |
@KevinKelchen and for anyone else looking to use esri types with Angular, here are some example usage snippets: Esri/angular-cli-esri-map#17 |
I always suspected @andygup was a Sasquatch hunter! That issue is like the Patterson Film for esri-loader. |
Thank you for those examples, @andygup ! I will give it a shot! 😃 |
@KevinKelchen @andygup @tomwayson I want to render our Mapping Application from MapViewer of our Portal for ArcGIS using Angular 7 Project.How I can do that.Please let me know. |
It sounds like you want to embed the map (or application) in your Angular application using an iframe. |
👆 this is a duplicate issue from here. I've sent Vipul an email. |
Hello Tom,
I don't want to use Iframe as it is not good practice, rest you can tell me
how we can do that.I have webbuilder package which I can get it embedded in
my Angular application, or I can embed esri map via portal id. But every
time the hit goes from arcgis, I am not able to get our mapviewer
application or map.Is there any way I can show the map viewer appkication
with widgits & layers in it in my Angular application.
Thanks & regards
Vipul Dua
…On Wed, Dec 19, 2018, 9:04 PM Tom Wayson ***@***.*** wrote:
@duavipul <https://github.com/duavipul>
It sounds like you want to embed the map (or application)
<https://doc.arcgis.com/en/arcgis-online/share-maps/embed-maps-groups.htm>
in your Angular application using an iframe.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#95 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFV4-_V0XXkK4u_TcWO1ALyXBsrqYozTks5u6lyGgaJpZM4SRKRO>
.
|
Hello @ALL
I am using Angular 5 CLI and JS API 3.23. I want to use us Map object as
import Map = require('esri/map');
But getting following error
Module not found: Error: Can't resolve 'esri/map'
Here is the Map component
import { Component, OnInit, ViewChild, ElementRef, Input, Output, EventEmitter } from '@angular/core';
import { loadModules } from 'esri-loader';
import Map = require('esri/map');
import Search = require('esri/dijit/Search');
@component({
selector: 'app-esri-map',
templateUrl: './esri-map.component.html',
styleUrls: ['./esri-map.component.css']
})
export class EsriMapComponent implements OnInit {
constructor(private elRef: ElementRef) { }
public ngOnInit() {
let map = new Map(this.elRef.nativeElement, {
center: [-118, 34.5],
zoom: 8,
basemap: 'streets'
});
}
}
If I use the following code on ngOnInit and comment the import map line then it works fine
const options = {
url: 'https://js.arcgis.com/3.23/'
};
loadModules(['esri/map'], options)
.then(([Map]) => {
// create map with the given options at a DOM node w/ id 'mapNode'
let map = new Map(this.elRef.nativeElement, {
center: [-118, 34.5],
zoom: 8,
basemap: 'streets'
});
})
.catch(err => {
// handle any script or module loading errors
console.error(err);
});
Thanks In advance
The text was updated successfully, but these errors were encountered: