Files architecture and best-practices working with map

Hello,

Im using pure cesium.js (not angular-cesium) in an angular application.

Can you please share from your experience what files architecture to use?(what are the best practices to add and update the map? Are there patterns for this?)

For example:
One map component, which use one service to draw anything on the map(circles, airplanes etc)

Thanks in advance.

Baruch

Hey Baruch,

How you build your application and organize your architecture depends on what you’re hoping to build and the scope of your project. But the singleton pattern of having the viewer object accessible by any part of your app is a common one I’ve seen.

What kind of project are you working on?

1 Like

Hello Baruch,

From the Angular framework perspective:

  1. I would create a wrapper Angular service for handling all Cesium-related tasks such as drawing that you mentioned. I would also expose the Cesium viewer object into that service as @omar already suggested.
    If you see that this service goes well beyond a reasonable size, try to break it up into smaller services that contain similar logic inside.

  2. I would also create an Angular attribute directive for the Cesium viewer object to handle initialization and other viewer-related stuff. I could then attach that to any Angular component.
    Typically, creating a directive instead of a component is more semantically correct because as per the Angular official documentation, attribute directives customize the behavior and appearance of an HTML element, which is what Cesium viewer does actually :wink:

1 Like

@omar @Aristeidis_Bampakos Thank you very much for your recommendation, i will try it! :slight_smile:

1 Like