Problem parsing JSON data in Google maps (i think)

Discussion in 'JavaScript' started by snails07, Sep 19, 2011.

  1. #1
    I have recently set up a mobile version of my site and am having a little trouble with the Google Maps V3 infowindows on the mobile version. I am trying to add some data from my JSON file to appear in the infowindows. I am totally new to JSON and javascript as well really. Here is the content string that I have for the infowindows on my main desktop site which is working perfectly.

    var contentString = '<div align="left"><p style="color:#000000;"><a href="http://publicaccessgolf.com.au/' + data.course[i].slug + '" >' + data.course[i].name + '</a><br />' + data.course[i].address + '<br />' + data.course[i].contact + '</p></div>';
    Code (markup):
    I want to add this to my mobile site but it will not work, the map either doesn’t display at all or there are no markers displayed. Here is part of the code for my mobile site

    function addMarker(map, position){
        var marker = $('#map_canvas').gmap('addMarker', { 'position':  position });
        var contentString = 'Need to add info in here...' ;
    
        var infoWindow = $('#map_canvas').gmap('addInfoWindow', { 'position':marker.get(0).getPosition(), 'content': contentString });
        marker.click(function() {
            infoWindow.get(0).open(map, marker.get(0));
            map.panTo(marker.get(0).getPosition());
        });
    }
    Code (markup):
    Any ideas why the code from the normal site would not be working??
     
    snails07, Sep 19, 2011 IP