ng-map vm.positions fail to refresh

I am currently utilizing the ng-map directive in conjunction with AngularJS. I have implemented the code below to generate markers. I store latitude and longitude values for each marker in an array, much like the examples shown here. Upon inspecting the logs, I can confirm that the information is accurate. However, the markers do not appear on my map.

Below is my AngularJS code:

var app = angular.module('myApp', ['ngMap']);
app.controller('mapController', function($interval, $http) {
    var generateMarkers = function() {
        var vm = this;
        vm.positions = [];
        $http.get("data").
            success(function(data) {
            console.log(data);
            console.log("array length: " + data.length);
            for (i = 0; i < data.length; i++) {
                var lat = parseFloat(data[i].latitud);
                var lng = parseFloat(data[i].longitud);
                console.log("position: " + lat + lng);
                vm.positions.push([lat, lng]);
                console.log("vm.positions", vm.positions);
            }   
        }).
        error(function (data) {
            console.log("failure");
        });
    };
  $interval(generateMarkers, 20000);
});

As for my HTML code:

 <ng-map zoom="14" center="[42.8169, -1.6432]" default-style="false">
  <marker ng-repeat="p in vm.positions" position="{{p}}"></marker>
</ng-map>

Here are the logged positions:

vm.positions [Array[2], Array[2], Array[2], Array[2], Array[2], Array[2], Array[2], Array[2], Array[2], Array[2]]0: Array[2]0: 42.8133161: -1.647981length: 2__proto__: Array[0]1: Array[2]0: 42.811868050589231: -1.635117530822754length: 2__proto__: Array[0]2: Array[2]0: 42.811868050589231: -1.639484167098999length: 2__proto__: Array[0]3: Array[2]0: 42.8139773239805951: -1.6452884674072266length: 2__proto__: Array[0]4: Array[2]0: 42.815834684266571: -1.6393446922302246length: 2__proto__: Array[0]5: Array[2]0: 42.8169010671877861: -1.6428154706954956length: 2__proto__: Array[0]6: Array[2]0: 42.8160038901641541: -1.6477882862091064length: 2__proto__: Array[0]7: Array[2]0: 42.811805086098651: -1.6448163986206055length: 2__proto__: Array[0]8: Array[2]0: 42.8174086747381: -1.6568756103515625length: 2__proto__: Array[0]9: Array[2]0: 42.805945172637361: -1.6659602522850037length: 2__proto__: Array[0]length: 10__proto__: Array[0].....(additional array information)

You can view the plnkr demo here: http://plnkr.co/edit/5uGUeyeuAie0TAFzIHMo?p=preview. This demo closely resembles the provided example but includes a GET Request to retrieve an array of latitudes and longitudes. Note that the updated version of the plnk has removed the GET Request and adjusted the data appropriately.

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

The React.js component search test encounters errors in locating components

I have been working on a React app that utilizes Redux and React-router. I am currently writing tests using React TestUtils, and I encountered an issue with the following test results: The first expect statement is successful: expect(nav).to.have.length(1) ...

Making requests from AngularJS $http/AJAX to a Node.js + Express.js API using POST, PUT, and DELETE methods

I recently developed a backend API using Node.js and Express.js v4. Here's a snippet of the code (index.js): app.use(function (req, res, next) { res.setHeader('Access-Control-Allow-Origin', 'http://example.com'); res.setHe ...

What is the best way to display a JavaScript object array on the screen

As someone who is new to JavaScript, I have a JavaScript object array that I would like to print the values of in the browser. However, I am unsure of how to do this without using document.write(vehicle); var vehicle = [{name:'Van',wheel:4,cha ...

Having trouble with SQLite and local storage in Android PhoneGap app specifically on Samsung Galaxy devices

My PhoneGap app is running smoothly on iOS and most Android devices, but I'm encountering an issue specifically with Samsung Galaxy S3 and S4. Upon the initial page load, the app creates a local SQL database to store question and answer values. Howev ...

Does using AJAX with jQuery and PHP guarantee that the response will always be in JSON format?

While working on PHP validation with AJAX requests for user-submitted information, I encountered an issue. The problem arises when attempting to convert the JSON response from PHP to a Javascript object, as it throws the following error: "Uncaught SyntaxE ...

There was an error: process is not defined / Line 0: Parsing error

When starting a basic Create React App project, I typically begin by running npm install. Next, executing npm start will automatically open the default web browser1. Upon pressing F12, two error messages are displayed in the console. https://i.sstatic.net ...

Using React to showcase a base64 image representation

I'm struggling to show an image that has been sent from my Node/Express server to my React application. I've tried looking at solutions on other platforms, but so far nothing has worked for me. Let me outline the steps I have taken: The image is ...

Steps for configuring UI-Router to open a new tab

I have a link on the homepage that directs users to a second page with two tabs. I want the second tab to be active by default so that users can see its content immediately. I tried using ui-sref, but it only takes me to the second page without activating ...

Ways to merge two arrays into one in React JS

Here are two arrays presented below: const arrayA = { 0: { id: XXXXXXX, name: "test" }, 1: { id: YYYYYYY, name: "example" } } const arrayB = { 0: { id: XXXXXXX, category: "sea", } 1: { id: YYYYY ...

Is there a way to make the submit button navigate to the next tab, updating both the URL and the tab's content as well?

I am encountering an issue with my tabs for Step1 and Step2. After pressing the submit button in Step1, the URL updates but the component remains on tab1. How can I resolve this so that the user is directed to the Step2 tab once they click the submit butto ...

Keep your filter content up-to-date with real-time updates in Vue.js

I am facing an issue with a markdown filter where the content of component.doc is set to update through a websocket. Despite updating the scope's component, the filtered content remains unchanged. Is there a way to dynamically refresh the v-html in t ...

Using Javascript, declare a constant variable within a try block

Can a variable be set inside a try{} block using const in strict mode with ES6? 'use strict'; const path = require('path'); try { const configPath = path.resolve(process.cwd(), config); } catch(error) { //..... } console.log ...

Access the array values by their respective keys in an object that is returned from a custom JavaScript file utilizing the Node.js file system

I recently came across a config file with a unique format, as shown below: define([], function () { return { productItems: { item1: ['Apple', 'Ball', 'Car'], item2: [&apo ...

Is it necessary to make a distinct route for SocketIO implementation?

I am new to Socket.IO and I recently completed the chat tutorial in the documentation along with some additional tasks to gain a better understanding of how it works. Currently, I am attempting to establish a connection between a NodeJS server and a React ...

What is the best way to create a div that extends beyond the borders of the screen, but still allows only

I am currently working on a React project for a website. I am creating a category bar that should slide only the component in the mobile version, without moving the entire page. Check out the desired design here However, the current appearance is differe ...

Double Assignment in JavaScript

Can you explain the concept of double assignment in ExpressJS and its functionality? An illustration is provided below using a code snippet from an ExpressJS instance. var server = module.exports = express() ...

The function provided to jQuery's one() method will only be executed the first time the event is triggered

Greetings from a newbie in the world of javascript! I am currently experimenting with creating custom menu transitions using some basic jquery code. The concept is to have a menu that is visible initially, and when the user clicks "close," the menu will ...

Determine the DOM element that corresponds to a right-click action

I utilized the code snippet below to construct a personalized context menu: <script type="text/javascript"> $(document).ready(function() { var x, y; document.oncontextmenu = function(e) { e.preventDefault(); x = e.clientX; ...

Searching and Substituting Elements with jQuery in a Text String

After making an Ajax call, I have retrieved HTML as a string. headings .... <div class="wrapper"> <input type="text" name="email" value="" /> </div> .... I have extracted the .wrapper and input elements from the HTML string. var el ...

Ways to specifically load a script for Firefox browsers

How can I load a script file specifically for FireFox? For example: <script src="js/script.js"></script> <script src="js/scriptFF.js"></script> - is this only for Firefox?? UPDATE This is how I did it: <script> if($. ...