My pen doesn't accurately display the ID

CHALLENGE

 var shoppingCenters = [{

  id: 0,
  name: 'Leclerc',
  location: 'Paris,France',
  address:'Boulevard Rahal El Meskini Casablanca Maroc',

  ]

},

{
  /*Malls B*/
  id: 1,
  name: 'Carefour',
  location: 'Toulouse, France',
  address:'Angle Zaid Ou Hmad Rue Sidi Belyout, Casablanca Maroc',  
}];

CUSTOM CONTROLLER

 var address = "";
var id_mall ="";
var shoppingCenters = ShoppingCenters.all();
for (var i = 0; i < shoppingCenters.length; i++) {
   center = shoppingCenters[i];
   addMarker(center);
}




function addMarker(address) {

    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var mapOptions = {
        zoom: 14,
        center: latlng
    }
    id = center.id;
    address = center.address;
    console.debug(address);
    map = new google.maps.Map(document.getElementById('map'), mapOptions);

    geocoder.geocode( { 'address': address}, function(results, status) {

        if (status == google.maps.GeocoderStatus.OK) {
             map.setCenter(results[0].geometry.location);

             var marker = new google.maps.Marker({
                map: map,
                title: 'shopping center',
                position: results[0].geometry.location,
                url:'#/tab/malls/'+id
            });
            google.maps.event.addListener(marker, 'click', function() {
                window.location.href=marker.url;
            });
        } else {
            alert('Geocode was not successful for the following reason: ' + status);
        }

    });

}

When clicking on a marker, it shows /tab/malls/1 even though there are two markers and should display /tab/malls/0 as well. I'm unable to find a solution.

Seeking assistance, thank you.

Answer №1

The code you have provided seems to be incorrect as there is an unpaired ] symbol on line 8. Please remove this symbol and attempt running the code again.

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

Encountering a running error in a Strongloop tutorial

I have been reviewing the Strongloop documentation and decided to try out the tutorial on how to Add a client app. I followed all the steps provided and was able to successfully run the app using slc run without encountering any errors. However, upon check ...

What could be causing the "undefined property read" error even though the data is clearly defined?

export async function getPrices() { const res = await fetch( "https://sandbox.iexapis.com/stable/crypto/BTCUSD/price?token=Tpk_1d3fd3aee0b64736880534d05a084290" ); const quote = await res.json(); return { props: { quote } }; } export de ...

Is there a way to verify the results of a Python script within a PHP webpage?

For my school project, I am creating a PHP website where I want to implement a Python code Quiz. I envision a scenario where users can input Python code in an on-page editor/IDE and the output is checked automatically using PHP If-function to determine cor ...

Can OR be utilized within a find operation?

I am currently developing a social media platform similar to Facebook using Express and MongoDB. One of the features I'm working on is adding friends to user profiles. When a user clicks on a button that says "Send Friend Request" on another user&apos ...

JavaScript => Compare elements in an array based on their respective dates

I have an array consisting of more than 50 objects. This array is created by concatenating two arrays together. Each object in this array contains a 'date' key with the date string formatted as: `"2017-03-31T11:30:00.000Z"` Additionally, there ...

Are you transitioning from traditional scroll pagination to using ajax?

Is it possible to replace scroll pagination with ajax? I'm looking for an alternative to the large scroll pagination query and wondering if ajax could be used instead. Here is the current code snippet: feeds.scrollFeedPagination({ 'contentPage ...

Using a combination of radio buttons and JavaScript to adjust the color of a div element

Currently, I am experimenting with radio buttons to modify the background color of my div tag. My goal is to incorporate more than one condition. For example, if button A and button B are both clicked, then change the color to green. This is what I have im ...

What is the best way to incorporate (+/-) buttons to increase or decrease numbers in this code snippet?

Hey everyone, I hope you're all doing well! I need some assistance in transforming this quantity picker from a dropdown to have buttons like the one shown here with plus and minus symbols: https://i.stack.imgur.com/O0uUa.png I would like to impleme ...

Tips for transferring a file to PocketBase using NodeJs

Currently, I am in the midst of a project that necessitates uploading numerous PDF files to a PocketBase collection. All the necessary files are saved on my computer and my goal is to upload them using nodejs along with the PocketBase JavaScript SDK. Howe ...

Encountering issues with tesseract callbacks in nodejs due to validation errors

I encountered the following error: fs.js:132 throw new ERR_INVALID_CALLBACK(); ^ TypeError [ERR_INVALID_CALLBACK]: Callback must be a function at makeCallback (fs.js:132:11) at Object.fs.unlink (fs.js:1002:14) at /home/bakedpanda/Documents/BTP/ ...

What is the best way to align text in the center of a div?

I just created this dropdown menu, but I am encountering an issue. Whenever I resize the div or h4 element, the text ends up at the top. Even after trying to solve it with text-align: center;, the problem persists. Here is a visual representation of what ...

Hovers and click effects for navigating through images

The website I'm currently working on is stipz.50webs.com. p.s. HOME functionality is not active at the moment. Having successfully implemented the onhover and onmouseout features, my next goal is to enhance the navigation effects for each div/img so ...

Looping through an object with AngularJS's ng-repeat

Upon receiving an object as the scope, which has the following structure: https://i.sstatic.net/hiBaw.png The controller function is defined as follows: module.controller('ActiveController', ['$scope','$http', func ...

Is there a way to toggle a command for a specific discord server rather than enabling it for all servers where the bot is present?

I've been working on a Discord bot with multiple commands managed by a custom command handler. However, I'm facing an issue where enabling a command affects all servers the bot is in. How can I implement a system using message.guild.id to toggle ...

"Utilizing JQuery to enhance task management by implementing a delete function

I need help figuring out how to create a function that can delete tasks from my todo list. Currently, each task has its own remove button, but I want to implement a single remove button at the bottom that removes checked or crossed out tasks. Any suggestio ...

When attempting to integrate Angular 1.4's new router with components, an issue arises where a warning is triggered stating, "Failed to instantiate controller HeadlinesController

Attempting to work with Angular for the first time and struggling to load a component using data from an http request. Currently encountering a warning when attempting to execute the code with the HTTP request. Receiving a "Could not instantiate control ...

My AJAX function is not functioning as intended

I'm currently developing a time management system for my workplace. As I was coding, I implemented a feature that allows users to configure the database details similar to the setup process in WordPress. Once the data is saved successfully, I aim to d ...

Incorporate Ng-Survey multiple times within one component

Incorporating the ng-surveys template into my Angular application via has been successful. However, I encountered an issue where when using the template selector *ngFor to display multiple surveys on the same page, the browser treats all the surveys as id ...

Ways to showcase the object on the console

How can I display the object function in the console? When I try, nothing is displayed. Can you please help me figure out what went wrong? I know I must have made a mistake somewhere, as this is my first question on Stack Overflow. import React, ...

Ways to attribute a numeric worth to a choice in a JavaScript form

I am in the process of creating a form that allows users to customize and order pizza while showing them the invoice as they make their selections. Currently, I have successfully implemented the display of user-selected options, but I am struggling with a ...