Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9256915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:05:28+00:00 2026-06-18T12:05:28+00:00

I am pulling in my marker data via JSON. When i was developing my

  • 0

I am pulling in my marker data via JSON.
When i was developing my local copy i had this in a JS file and just called it using

<script src="assets/js/locations.js"></script>

I am now moving the site onto a CMS (ExpressionEngine) and because the marker data is dynamic I have a JS template which now holds the JSON data.

I now have to include the file as (notice that there is no file extension)

<script src="http://domain.com/map/locations"></script>

Here is an example of the JSON I have.

var locations = [

    [2, 51.39006, -0.02976, 'telecommunications', 'Test 2', '<div><img src="http://localhost/map/assets/graphics/info_window/default.jpg" alt="Test 2" width="105" height="70" style="float:right;"> <p>fdgj fdh uhfj bfd nibjdfjb ndfjn fd vfn vbjdc&nbsp; ifs n ei klmvf.cx fi fskn d</p></div>', '<a href="http://www.yahoo.com" target="_blank">Read more</a>' ],   
    [1, 51.51400, -0.12002, 'transport', 'Test map marker', '<div><img src="{image:url:thumb}" alt="Test map marker" width="{image:width:thumb}" height="{image:height:thumb}" style="float:right;"> <p>eubnglrsk nekfldb jndklvcbv jdnfhl kvbmd klbndvl kbjn dkbnm lkd nbmfljeb ygdjfjn</p></div>', '<a href="http://www.google.com" target="_blank">Read more</a>' ]  

];

This is the marker loop for the map

var markers = [];

    // Looping through the JSON data
    for (var i = 0; i < locations.length; i++) {

        // Creating a marker and putting it on the map
        var marker = new google.maps.Marker({
            position: new google.maps.LatLng(locations[i][1], locations[i][2]),
            map: map,
            title: locations[i][4],
            icon: iconSrc[locations[i][3]]
        });
        markers.push(marker);


        google.maps.event.addListener(marker, 'click', (function(marker, i) {
            return function() {
                infoWindow.setContent("<div class='cont_box' id='" + locations[i][0] + "'>" + "<h2>" +locations[i][4] + "</h2>" + "<div class='cont'>" + locations[i][5] + "</div><div style='clear:both;'></div><div class='link'>" + locations[i][6] + "</div></div>");
                infoWindow.open(map, marker);
            }
        })(marker, i));

    }// END for loop

Obviously the error I get when I reference the JSON data rendered by the CMS is ::

ReferenceError: locations is not defined

The URL is valid, just it doesn’t seem to be pulled in like when i use a JS file.

I don’t know if it would be better for me to call the file within the maps JS code itself.

Any suggestions on how I could make this work would be great

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:05:29+00:00Added an answer on June 18, 2026 at 12:05 pm

    I have 2 ideas.

    1. in your script tag declare the type (do you know if your overall page is html5?):
    <script type="text/javascript" src="http://domain.com/map/locations"></script>
    

    My other idea is to load your data in the code:

    var xhr = new XMLHttpRequest();
    xhr.open('GET', 'http://domain.com/map/locations', true);
    xhr.onload = function() {load you markers here}
    };
    xhr.send();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im pulling data from a MySql data table. I'm pulling from a row called
Pulling some data from MongoDB and inserting it into a MySQL database, using Python
Pulling my hair out over this one. I have one wordpress install at /2009
Im pulling a text file - it will be input by user currently its
I've been pulling my hair out with this function. It's a function within a
I have a query pulling the last six months of data from a table
I am modifying a theme and pulling data out of my PODS tables. I
Pulling my hair out with this simple CSS layout. I have a 2-column fixed
while pulling into my git repository from our central server, this error occured: $
After pulling my hair out trying to get my local IIS server to not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.