Ошибка синтаксического анализа json: SyntaxError: неожиданный токен <в JSON в позиции 0 с loadGeoJson - PullRequest
0 голосов
/ 29 октября 2019

Я забрал назначение у стажера на работе, и я не знаю, что он сделал, но я думаю, что он испортил сайт, над которым мы работаем. Он построен на Wordpress, и я пытаюсь создать локатор магазина с Google Maps без какого-либо плагина Wordpress, но с помощью этого метода: https://developers.google.com/maps/solutions/store-locator/simple-store-locator

Я пробовал этот урок на одном проекте, и все работалохорошо. Но когда я пытаюсь интегрировать его в основной веб-сайт, я получаю сообщение об ошибке: парсинг store.json: SyntaxError: неожиданный токен <в JSON в позиции 0 </p>

    map.data.loadGeoJson('stores.json', {idPropertyName: 'storeid'});
{
  "type": "FeatureCollection",
  "features": [{
    "geometry": {
      "type": "Point",
      "coordinates": [-0.1428115,
        51.5125168
      ]
    },
    "type": "Feature",
    "properties": {
      "category": "patisserie",
      "hours": "10am - 6pm",
      "description": "Modern twists on classic pastries. We're part of a larger chain of patisseries and cafes.",
      "name": "Josie's Patisserie Mayfair",
      "phone": "+44 20 1234 5678",
      "storeid": "01"
    }
  },
    {
      "geometry": {
        "type": "Point",
        "coordinates": [-2.579623,
          51.452251
        ]
      },
      "type": "Feature",
      "properties": {
        "category": "patisserie",
        "hours": "10am - 6pm",
        "description": "Come and try our award-winning cakes and pastries. We're part of a larger chain of patisseries and cafes.",
        "name": "Josie's Patisserie Bristol",
        "phone": "+44 117 121 2121",
        "storeid": "02"
      }
    },
    {
      "geometry": {
        "type": "Point",
        "coordinates": [
          1.273459,
          52.638072
        ]
      },
      "type": "Feature",
      "properties": {
        "category": "patisserie",
        "hours": "10am - 6pm",
        "description": "Whatever the occasion, whether it's a birthday or a wedding, Josie's Patisserie has the perfect treat for you. We're part of a larger chain of patisseries and cafes.",
        "name": "Josie's Patisserie Norwich",
        "phone": "+44 1603 123456",
        "storeid": "03"
      }
    },
    {
      "geometry": {
        "type": "Point",
        "coordinates": [-1.9912838,
          50.8000418
        ]
      },
      "type": "Feature",
      "properties": {
        "category": "patisserie",
        "hours": "10am - 6pm",
        "description": "A gourmet patisserie that will delight your senses. We're part of a larger chain of patisseries and cafes.",
        "name": "Josie's Patisserie Wimborne",
        "phone": "+44 1202 343434",
        "storeid": "04"
      }
    },
    {
      "geometry": {
        "type": "Point",
        "coordinates": [-2.985933,
          53.408899
        ]
      },
      "type": "Feature",
      "properties": {
        "category": "patisserie",
        "hours": "10am - 6pm",
        "description": "Spoil yourself or someone special with our classic pastries. We're part of a larger chain of patisseries and cafes.",
        "name": "Josie's Patisserie Liverpool",
        "phone": "+44 151 444 4444",
        "storeid": "05"
      }
    },
    {
      "geometry": {
        "type": "Point",
        "coordinates": [-1.689423,
          52.632469
        ]
      },
      "type": "Feature",
      "properties": {
        "category": "patisserie",
        "hours": "10am - 6pm",
        "description": "Come and feast your eyes and tastebuds on our delicious pastries and cakes. We're part of a larger chain of patisseries and cafes.",
        "name": "Josie's Patisserie Tamworth",
        "phone": "+44 5555 55555",
        "storeid": "06"
      }
    },
    {
      "geometry": {
        "type": "Point",
        "coordinates": [-3.155305,
          51.479756
        ]
      },
      "type": "Feature",
      "properties": {
        "category": "patisserie",
        "hours": "10am - 6pm",
        "description": "Josie's Patisserie is family-owned, and our delectable pastries, cakes, and great coffee are renowed. We're part of a larger chain of patisseries and cafes.",
        "name": "Josie's Patisserie Cardiff",
        "phone": "+44 29 6666 6666",
        "storeid": "07"
      }
    },
    {
      "geometry": {
        "type": "Point",
        "coordinates": [-0.725019,
          52.668891
        ]
      },
      "type": "Feature",
      "properties": {
        "category": "cafe",
        "hours": "8am - 9:30pm",
        "description": "Oakham's favorite spot for fresh coffee and delicious cakes. We're part of a larger chain of patisseries and cafes.",
        "name": "Josie's Cafe Oakham",
        "phone": "+44 7777 777777",
        "storeid": "08"
      }
    },
    {
      "geometry": {
        "type": "Point",
        "coordinates": [-2.477653,
          53.735405
        ]
      },
      "type": "Feature",
      "properties": {
        "category": "cafe",
        "hours": "8am - 9:30pm",
        "description": "Enjoy freshly brewed coffe, and home baked cakes in our homely cafe. We're part of a larger chain of patisseries and cafes.",
        "name": "Josie's Cafe Blackburn",
        "phone": "+44 8888 88888",
        "storeid": "09"
      }
    },
    {
      "geometry": {
        "type": "Point",
        "coordinates": [-0.211363,
          51.108966
        ]
      },
      "type": "Feature",
      "properties": {
        "category": "cafe",
        "hours": "8am - 9:30pm",
        "description": "A delicious array of pastries with many flavours, and fresh coffee in an snug cafe. We're part of a larger chain of patisseries and cafes.",
        "name": "Josie's Cafe Crawley",
        "phone": "+44 1010 101010",
        "storeid": "10"
      }
    },
    {
      "geometry": {
        "type": "Point",
        "coordinates": [-0.123559,
          50.832679
        ]
      },
      "type": "Feature",
      "properties": {
        "category": "cafe",
        "hours": "8am - 9:30pm",
        "description": "Grab a freshly brewed coffee, a decadent cake and relax in our idyllic cafe. We're part of a larger chain of patisseries and cafes.",
        "name": "Josie's Cafe Brighton",
        "phone": "+44 1313 131313",
        "storeid": "11"
      }
    },
    {
      "geometry": {
        "type": "Point",
        "coordinates": [-3.319575,
          52.517827
        ]
      },
      "type": "Feature",
      "properties": {
        "category": "cafe",
        "hours": "8am - 9:30pm",
        "description": "Come in and unwind at this idyllic cafe with fresh coffee and home made cakes. We're part of a larger chain of patisseries and cafes.",
        "name": "Josie's Cafe Newtown",
        "phone": "+44 1414 141414",
        "storeid": "12"
      }
    },
    {
      "geometry": {
        "type": "Point",
        "coordinates": [
          1.158167,
          52.071634
        ]
      },
      "type": "Feature",
      "properties": {
        "category": "cafe",
        "hours": "8am - 9:30pm",
        "description": "Fresh coffee and delicious cakes in an snug cafe. We're part of a larger chain of patisseries and cafes.",
        "name": "Josie's Cafe Ipswich",
        "phone": "+44 1717 17171",
        "storeid": "13"
      }
    }
  ]
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...