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

  • SEARCH
  • Home
  • 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 8547049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:10:50+00:00 2026-06-11T13:10:50+00:00

I am trying to get some json markers to display on my map. The

  • 0

I am trying to get some json markers to display on my map.

The map is actually appearing but no pointers are being displayed and the position of the map is way off.

Here is the js code:

<script>

    $('#map_canvas').gmap().bind('init', function() { 
    // This URL won't work on your localhost, so you need to change it
    // see http://en.wikipedia.org/wiki/Same_origin_policy
    $.getJSON( 'locations.json', function(data) { 
        $.each( data.markers, function(i, marker) {
            $('#map_canvas').gmap('addMarker', { 
                'position': new google.maps.LatLng(marker.latitude, marker.longitude), 
                'bounds': true 
            }).click(function() {
                $('#map_canvas').gmap('openInfoWindow', {'content': marker.content }, this);
            });
        });
    });
});
</script>

And here is the contents of the json file:

{"locations":[{"id":"14","location":"(50.8765125,
 -1.1504182944499557)"}]}

Is there anything wrong with the code?

  • 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-11T13:10:51+00:00Added an answer on June 11, 2026 at 1:10 pm

    From the structure of your json file I’d say your’re trying to access undefined properties of each item in data.markers. locations is an array of objects with two properties: id is a String and locations is an array of length 2. So why this code?

    marker.latitude
    marker.longitude
    marker.content
    

    Maybe you should try

    marker.location[0]
    marker.location[1]
    

    First you should confirm your json output:

    $.getJSON( 'locations.json', function(data) { 
        console.log(data);
    }
    

    And post it in your question…

    If it’s ok try like this:

    $.each( data.markers, function(i, marker) {
            $('#map_canvas').gmap('addMarker', { 
                'position': new google.maps.LatLng(marker.location[0], marker.location[1]), 
                'bounds': true 
            }).click(function() {
                $('#map_canvas').gmap('openInfoWindow', {'content': marker.id }, this);
            });
        });
    

    … Actually I’m not sure why you use data.marker also and not data.locations

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get some json data in my application, but it won't come
I'm trying to get some json from an action but I have a problem.
I'm trying to transfer Rails-generated json into Google Maps markers on a map, but
Im trying to figure out a way to get some JSON data transfered from
I am trying to get some errors returned in JSON format. So, I made
Just trying to get some rows out of a database and loop through but
Im trying to get some system information using WMI but the problem is when
I am trying to get facebook wall but I am having issues with JSON
I'm trying to get some json data from a remote website. I run my
I am trying to use dojo.xhrGet to get some json back from a php

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.