Encountering issues with reading undefined properties within azure-maps-animations

Attempting to reimplement the Azure Maps Animations example with TypeScript has been a challenging task for me. Here's the link to the sample:

I'm encountering several issues and could really use some assistance. I'll describe my problems and share my code below.

Upon running in Chrome, I encounter two errors in the console:

Uncaught TypeError: Cannot read properties of undefined (reading 'EventEmitter')
    at azure-maps-animations.js:1101:23
    at azure-maps-animations.js:3424:2

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'moveAlongRoute')
    at main.ts:96:41

In an attempt to utilize VSCode and RequireJs, I specified the following options in tsconfig.json:

  "compilerOptions": {
    "module": "AMD",
    "target": "ES6",
    "moduleResolution": "node",
    "esModuleInterop": true,

    "strict": true,
    "jsx": "preserve",
    "sourceMap": true,
    "declaration": false,
    "lib": ["ES6", "DOM"],
    "resolveJsonModule": true,
    "downlevelIteration": true,

    "outDir": "./js",
    "rootDir": "./ts",
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "typeRoots": [
      "./node_modules/@types",
      "./types"
    ],
    "baseUrl": "./",
    "paths": {
      "azure-maps-control": ["node_modules/azure-maps-control/dist/atlas.min"]
    },
  }

The configuration file config.js was utilized to set up RequireJS:

require.config({
  baseUrl: './js',
  paths: {
    'azure-maps-control': 'https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas'
    ,'azure-maps-animations': '../lib/azure-maps/azure-maps-animations'
  }
});

require(['main'], function(main) {
});

The HTML page only contains:

<head>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js" defer></script>
    <script src="./node_modules/requirejs/require.js" defer></script>
    <script src="./config.js" defer></script>
    <link href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.css" rel="stylesheet" />
</head>
<body>
    <div id="myMap"></div>
</body>

This is the content of the main.ts file:

[...]

If I uncomment //anim.play(); I get: Property 'play' does not exist on type 'RoutePathAnimation'.

If I uncomment //timestampProperty: 'timestamp', I get: 'timestampProperty' does not exist in type 'RoutePathAnimationOptions'

I noticed that the sample uses atlas namespace for both control and animations imports, I don't know how to do this, could it be the issue ?

The file ../lib/azure-maps/azure-maps-animations.js comes from https://github.com/Azure-Samples/azure-maps-animations/blob/main/dist/azure-maps-animations.js

The file /types/azure-maps-animations.d.ts comes from https://github.com/Azure-Samples/azure-maps-animations/blob/main/typings/index.d.ts

The concept of "timestampProperty" intrigues me and I would like to implement it. Could you please assist me in understanding these issues?

Thank you.

Answer №1

There is a bug in the moveAlongRoute options as it does not include a timestampProperty option. This bug can be fixed by commenting out or deleting that part of the code. However, this bug does not impact JavaScript functionality as it is simply ignored.

It's important to note that the moveAlongRoute function requires all points to have a property named _timestamp. If your timestamp information is stored in a different property, you will need to pass your points through the extractRoutePoints function first, which does have a timestampProperty option.

This library also relies on access to the atlas namespace from Azure Maps.

To provide access to the atlas namespace in your code, you can do so like this:

import * as atlas from "azure-maps-control";

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

combine several arrays next to each other based on a specified key

I have a collection of three sets, each containing three elements: Set1 = [[apple, 2, 4], [banana, 5, 5], [cherry, 4, 1]] Set2 = [[banana, 1, 7], [cherry, 3, 8], [date, 5, 4]] Set3 = [[apple, 5, 2], [banana, 0, 9], ...

Error encountered while attempting to serialize React Fragment: Symbol value cannot be converted to a string

Encountering an issue while attempting to render a React.Fragment: Error Message: Cannot convert a Symbol value to a string Snippet of the code being passed to a component: render{ const block = { type : 'menu', className: &ap ...

Using Javascript to efficiently remove elements with AJAX

Currently, I am learning the basics of HTML and focusing on tasks such as login/logout functionality, creating users, and deleting users (only permitted when logged in as an admin). For updating a user password, I have utilized PUT, for creating a user ac ...

Having trouble with implementing image resizing and cropping in a Node.js environment

Struggling with image processing in node js, this task is crucial for my application. The goal is clear: 1) User uploads an image (multipart formdata sent to the server - successful) 2) Resize the image to a max width of 640px 3) Crop the picture within s ...

Instantly display modal upon website loading

Adding more context to the title, I have a modal that was included in a purchased template and it was originally set to only open when a button is clicked. However, I want the modal to automatically pop up when the page loads. The issue is that the modal ...

Is it possible to integrate ng-repeat with ng-model in Angular?

Is it possible to link the ng-model of a button with the ng-repeat loop? <a ng-repeat="x in [1,2,3,4]" ng-model="myButton[x]">{{myButton[x]}}</a> In the Controller: var id = 4; $scope.myButton[id] = ' :( '; I am interested in crea ...

Creating dynamic and interactive web pages can be achieved by utilizing either $_POST or $_GET with Modal,

In the snippet below, you'll find the HTML code that pulls an array of 6 objects from a database and displays them in a Bootstrap row successfully. <div class="row products"> <?php while($product = mysqli_fetch_assoc($featured)) ...

Specifying the type of "this" within the function body

After going through the typescript documentation, I came across an example that explains how to use type with this in a callback function. I am hoping someone can assist me in comprehending how this callback will operate. interface DB { filterUsers(fil ...

Is it possible to animate the innerHTML of a div using CSS?

In my HTML file, I have these "cell" divs: <div data-spaces class="cell"></div> When clicked, the innerHTML of these divs changes dynamically from "" to "X". const gridSpaces = document.querySelectorAll("[data-spaces]"); f ...

Incorporating a YouTube channel onto a website with React and Typescript, only to be greeted with a

After executing the following code snippet, everything runs smoothly, except for the YouTube player displaying a 404 error. I suspect that there might be an issue with the embedded URL. In the code below, I define a constant called YouTubePlayer which lo ...

Three pie or doughnut charts instead of one are utilized within Chart.js

Can multiple charts be nested inside one another? To see an example of a single chart and what I would like - where the first one is placed inside the second one and so on - please refer to this js fiddle. var data = [ { label: "title 1", value: ...

Having trouble executing "npm install" following the clone from GitHub in React

After cloning a repository from GitHub, I attempted to run "npm install" but encountered the following error: https://i.sstatic.net/QM4RZ.png Since the project is still in development, should I install or add anything else to successfully run it? ...

Animating Page Transitions within Ionic 2

In my Ionic 3 application, I have a basic tabs template where I switch between tabs by swiping left or right. Everything works perfectly except there is no animation effect when transitioning between tabs either by tapping or swiping. I am able to achieve ...

What is the method for obtaining the number of weeks since the epoch? Is it possible to

Currently, I am setting up a DynamoDb store for weekly reporting. My idea is to use the week number since 1970 as a unique identifier for each report record, similar to epoch milliseconds. Here are some questions I have: How can I determine the current w ...

The arrow function in Jest is missing a name property

Currently, my setup includes: node.js: 9.8.0 Jest: 23.4.2 ts-jest: 23.1.3 typescript: 2.9.2 While attempting the following in my *.test.ts files: const foo = () => 'bar'; console.log(foo.name); // '' foo contains the name pro ...

What is the best way to customize the style using a CSS class?

Is it possible to alter a specific style with a CSS class using jQuery or JavaScript? For example, if the HTML looks like this: <tab> <a class="anchor">a</a> </tab> And the CSS looks like this: a {border:1px} .anchor {color: ...

Looking to combine cells within a table using the Exceljs library

Encountered an issue while generating a worksheet in the EXCELJS library. function save_export(){ var workbook = new ExcelJS.Workbook(); var worksheet = workbook.addWorksheet('sheet', { pageSetup:{paperSize: 9, orientation:' ...

Utilize Observables to track changes in Ionic 2 form input elements

Is there a way to create an Observable from an Ionic 2 form element without directly accessing the DOM? While the Observable.fromEvent function is useful for events, I have the form element reference from the FormBuilder service, not the actual element it ...

JavaScript offers a variety of options for creating a link-styled button

Is there a distinction between <a href="javascript:;"></a> and <a href="javascript:void(0);"></a> ? I am looking to create a link-styled button that triggers a JavaScript function when clicked, so I implement the following: ...

Toggle the visibility of a section in an external .js file

Is there a way to toggle the display of answers from an external .js file using a button? If I were able to modify the code, I could wrap the answers in a div. However, since it's an external .js file, is this feasible? Here's the fiddle and cod ...