0

I used Google API to create a map of places to drink for a project. It works when I tested a couple of data items, but it stopped when I added more? I'm wondering where to start to fix this problem - can anyone help?

Thank you in advance.

Here is my code:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer.js" type="text/javascript"></script>
</head>
<body>
<script>
    var json = [
        {
            "title": "320 Main",
            "lat": 33.7432219,
            "lng": -118.103218,
            "description": "320 Main is a Tesla-esque lab for cocktail experimentation. Old-Fashioneds come out with the frequency of water with ice, and mustard isn't just a condiment for fries; it also comes in drinks."
        },
        {
            "title": "The Playground",
            "lat": 33.7477745,
            "lng": -117.865719,
            "description": "Here chef Jason Quinn exhibits the ballsy confidence that's gotten him this far. The Playground's famous burger is the bloodiest in all of OC, for instance, but it's also one of the greatest."
        },
          {
            "title": "Noble Ale Works",
            "lat": 33.808411,
            "lng": -117.882799,
            "description": "Noble Ale Works' double IPA, Tongue Tickles, may be the best beer it's ever brewed. Plus, you can park there for free on game nights, have a great beer for five bucks, and then walk to Angels Stadium or the Pond."
        },
          {
            "title": "Valiant Brewing",
            "lat": 33.8255472,
            "lng": -117.8641555,
            "description": "The owners of Valiant Brewing Company (a husband and wife team) have an evident passion for perfecting craft beer. Their specialty is in ales, particularly those over 8% abv."
        },
          {
            "title": "Broadway by Amar Santana",
            "lat": 33.5428096,
            "lng": -117.7821256,
            "description": "At Broadway by Amar, you'll get drinks that are exquisitely balanced—like their Santa Prisca Swizzle. Expect to be refreshed—never overwhelmed."
        },
          {
            "title": "The Cellar",
            "lat": 33.4264417,
            "lng": -117.6146645,
            "description": "One of the county's last places for classic French cuisine, in a downstairs setting perfect for its fine dining atmosphere."
        },
          {
            "Harlow's Kitchen & Craft Bar",
            "lat": 33.5083731,
            "lng": -117.6587784,
            "description": "At Harlow's, you'll find farm-to-table seasonal fare and a delightful craft bar. You'll want to try Old Fashioned, which comes with cherries cured in spice syrup."
        },
          {
            "title": "Three Seventy Common",
            "lat": 33.5425307,
            "lng": -117.7820889,
            "description": "Three Seventy Common is cozy and rustic restaurant in Laguna Beach with incredibly in-depth and beautiful, American comfort food. You will find tasty small bites, juicy scallops, the perfect steak, toasty mac and cheese, exotic bone marrow, and impeccable sides."
        },
          {
            "title": "Pub at Fiddler's Green",
            "lat": 33.7948668,
            "lng": -118.0552037,
            "description": "Fiddler's Green is a bar in Los Alamitos. It's the last military bar left in OC, positioned on the Los Al Joint Forces Training Base."
        },
          {
            "title": "The North Left",
            "lat": 33.7480046,
            "lng": -117.8697248,
            "description": "The North Left is what replaced the Crosby. But for all intents, the North Left is the same restaurant Phil Nisco, Chris Alfaro and Marc Yamaoka once opened, even if it doesn’t look like it."
        },
          {
            "title": "Juliette Kitchen and Bar",
            "lat": 33.657849,
            "lng": -117.8665962,
            "description": "Juliette Kitchen and Bar is a place for good conversations, drinks with friends—oh, and food. Ask for the smoked ocean trout salad. You won't have a sharper, more complex plate of food involving arugula than this."
        },
          {
            "title": "Pizzeria Ortica",
            "lat": 33.6903721,
            "lng": -117.8831607,
            "description": "Pizzeria Ortica's pizzas are blasted in a wood-burning oven that reaches up to 900 degrees. Th result? A blistered crust that will make you feel like you're tasting pizza for the first time."
        },
          {
            "title": "Anepalco's Café (at the Ayres Hotel)",
            "lat": 33.7895588,
            "lng": -117.8915762,
            "description": "At Anepalco's Café on Chapman, Baguettes are served with guajillo chile butter. Dessert is from a roster of crepes that include one with Nutella and banana. The single best dish, though, is a pan-sautéed tilapia where Godinez turns a bargain fish into something as delicate as seabass."
        },
          {
            "title": "The Globe Belgian Gastropub",
            "lat": 33.7555024,
            "lng": -117.9984994,
            "description": "Start with a Belgian draft beer poured into a curvy chalice, or try one of more than a dozen Trappist brews, artisan beer produced by a select few monasteries, largely in Belgium."
        },
          {
            "title": "Lola Gaspar",
            "lat": 33.7463008,
            "lng": -117.8690729,
            "description": "Lola Gaspar is a bar more than it’s a restaurant since it’s in a room so small it couldn’t serve as the waiting area for your local Black Angus. Your first order of business here should be a glass of sangria ladled from a big jug, then an order of hot bacon wrapped dates with blue cheese."
        },
          {
            "title": "Posse Bar",
            "lat": 33.7728759,
            "lng": -118.023379,
            "description": "Posse Bar is that rarest of breeds in OC: a completely unpretentious, normal, middle-class American bar, with friendly bartenders, great prices (especially at happy hour, which extends all day on Sunday) and a fun, happy crowd."
        },
          {
            "title": "Cismontane Brewing Company",
            "lat": 33.6366357,
            "lng": -117.609366,
            "description": "Cismontane Brewing Co. is full of Southern Californian pride: started by two native southern Californians, it creates beers named after local features."
        },
          {
            "title": "C4 Deli",
            "lat": 33.7464613,
            "lng": -117.869922,
            "description": "C4 Deli is a deli in Santa Ana. It’s housed in a doozy of a room, with a soaring ceiling, Gatsby-esque Art Deco design motifs, exposed brick walls, and a window that stares directly at the equally beautiful Santora building across Broadway. Get the Reuben."
        },
          {
            "title": "Mineshaft Bar",
            "lat": 33.7675122,
            "lng": -118.1709261,
            "description": "No matter where in the gayborhood you start your pub crawl, you will end up at Mine Shaft. This bar is all things to all people, with a comforting minimum of the trappings of a post-Stonewall gay bar: There is no porn on the television, no neon penis signs, and the bartenders are dressed as bartenders."
        },
          {
            "title": "Alex's Bar",
            "lat": 33.7828017,
            "lng": -118.1573649,
            "description": "Everyone loves Alex's Bar for the amazing music, for its cameo as Fangtasia on True Blood, for its griminess and sheer beauty, but within these walls lies a bona fide cocktail program."
        },
          {
            "title": "Barley Forge Brewing Co.",
            "lat": 33.6787002,
            "lng": -117.8882863,
            "description": "Barley Forge's initial beers, brewed on Nylen's pilot batch system in the Santa Monica Mountains, and they're good; he's deliberately thinking about beer that can be paired with food."
        },
          {
            "title": "Johnny's Saloon",
            "lat": 33.7091941,
            "lng": -117.9883462,
            "description": "Led by owner Johnny Kresimir's behemoth social-media following and the bar's die-hard regulars, patrons flock to this bar not only to drink from the 100 craft whiskeys and beers offered, but also to donate money, clothes, time and goods to members of the community who need it most."
        },
          {
            "title": "Bosscat Kitchen",
            "lat": 33.670023,
            "lng": -117.8653105,
            "description": "Bosscat Kitchen & Libations is a southern restaurant in Newport Beach. Its chef, Peter Petro, is fluent in okra and cornbread in a menu that’s as Southern-accented as Polly Holliday’s Flo."
        },
          {
            "title": "Take 5",
            "lat": 33.6632423,
            "lng": -117.9710362,
            "description": "Welcome to the new old dive bar, a neighborhood hangout straight out of a sitcom set in an industrial Midwestern city, with a strange beer selection, more flavored alcohol than anyplace north of Ladera Ranch, and patrons who actually talk to one another."
        },
          {
            "title": "Memphis Cafe",
            "lat": 33.6768746,
            "lng": -117.8866391,
            "description": "For $20, you can buy a veritable three-course meal, plus a cocktail, at Memphis Cafe's happy hour. From 3 to 6:30 p.m. daily, the sweet, stylish, southern-comfort restaurant and bar offers up its tastiest plates starting at $5 apiece, with cocktails starting at just $4."
        },
          {
            "title": "The Quill",
            "lat": 33.7590317,
            "lng": -117.8438493,
            "description": " Next to a liquor store, the Quill is what a neighborhood bar should be, attracting regulars and newcomers of all ages, ethnicities and economic classes."
        },
          {
            "title": "Kelly's Korner Tavern",
            "lat": 33.8897058,
            "lng": -117.8471695,
            "description": "Tucked away in the nook of a Placentia strip mall, this bar generously serves up a wealth of distractions along with its beer selection."
        },
          {
            "title": "Las Vegas Bar",
            "lat": 33.7155251,
            "lng": -117.8852988,
            "description": " While the nights at Las Vegas Bar feature working-class Mexicans ready to get borracho on Mexican, Salvadoran, even Guatemalan cervezas, daytime at this SanTana standard is a more languid affair, bringing in viejitos in guayaberas, union guys drinking some cold ones for lunch and plebes with nowhere to go."
        },
          {
            "title": "The V Room",
            "lat": 33.7717053,
            "lng": -118.1808523,
            "description": "V Room is a true whole-in-the-wall—an ideal spot for drinkers low on snobbery and high on, well, want for booze."
        },
          {
            "title": "Native Son Alehouse",
            "lat": 33.748232,
            "lng": -117.8652571,
            "description": "Beers from local breweries such as Bottle Logic Brewing, Noble Ale Works, Smog City Brewing, Monkish Brewing, The Bruery and more are on tap at Native Son Alehouse. Locality aside, there are also brews from Germany, Belgium, Canada, Japan, and England."
        },
          {
            "title": "Past Memories",
            "lat": 33.7734514,
            "lng": -117.9696792,
            "description": "Combine Past Memories' yogurt soju, food (especially the fried chicken), the cajoling company of friends, and the 2 a.m. closing time, and its slowly mounting effects can be easily underestimated until "The Past Memories" becomes more than just the restaurant's name."
        },
          {
            "title": "Anthill Pub",
            "lat": 33.6467505,
            "lng": -117.8454963,
            "description": "Some schools discourage drinking; others ban it. And then there's UC Irvine, whose Anthill Pub in the Student Center bans drinking crappy beer."
        },
          {
            "title": "The Goathill Tavern",
            "lat": 33.6412691,
            "lng": -117.9182082,
            "description": "The very definition of casual, Goat Hill greets its guests with a floor covered in peanut shells, a huge block of a man checking IDs and a subtle scent of . . . what the hell is that smell, anyway?"
        },
          {
            "title": "The Bruery",
            "lat": 33.8619002,
            "lng": -117.8802111,
            "description": "Whether you're at the bar sipping the fragrant Trade Winds triple, along the walls with the pitch-black Tart of Darkness sour stout or setting down a glass of the hop-tastic Loakal Red at beer barrels turned into beer tables, anybody who wants to have a great time tasting suds will be right at home here."
        },
          {
            "title": "Beach Ball",
            "lat": 33.6089575,
            "lng": -117.9290921,
            "description": "It's easy to pass by this hole-in-the-wall bar near the Newport Pier, but Beach Ball is a dive at its best—with cheap, stiff drinks and a loyal following. This is not a place to order prissy, girly martinis. Instead, go for beer or well drinks; you won't be disappointed."
        },
          {
            "title": "The Blind Donkey",
            "lat": 33.7690476,
            "lng": -118.1865789,
            "description": "Located in the basement of the Broadlind Hotel in Long Beach's East Village Arts District, The Blind Donkey has more than 100 whiskeys from around the world."
        },
        {
            "title": "Steamers",
            "lat": 33.8700253,
            "lng": -117.9258896,
            "description": "The only jazz club in downtown Fullerton, it's open to all ages and serves pizzas, panini and focaccia sandwiches along with Cajun- and Thai-inflected dishes."
        }
    ]
    var myCenter=new google.maps.LatLng(33.6700, -117.7800);
    function initialize()
    {
    var mapProp = {
    center:myCenter,
    zoom:10,
    mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);

var infowindow =  new google.maps.InfoWindow({
    content: ""
});

for (var i = 0, length = json.length; i < length; i++) {
    var data=json[i];
    var latLng = new google.maps.LatLng(data.lat, data.lng); 
    // Creating a marker and putting it on the map
    var marker = new google.maps.Marker({
        position: latLng,
        map: map,
        title: data.title
    });

    bindInfoWindow(marker, map, infowindow, data.description);
} 
}

function bindInfoWindow(marker, map, infowindow, strDescription) {
google.maps.event.addListener(marker, 'click', function() {
    infowindow.setContent(strDescription);
    infowindow.open(map, marker);
});
}
    google.maps.event.addDomListener(window, 'load', initialize);
</script>
<div id="googleMap" style="width:100%;height:100%;"></div>

</body>
//Copyright 2004 Luke Mahe

//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at

//   http://www.apache.org/licenses/LICENSE-2.0

//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
</html>
1
  • Problem Solved: I had syntax errors in my JSON. Dr. Molle was right!
    – Kristine
    Jan 29, 2015 at 20:08

1 Answer 1

2

Your JSON is corrupt.

  • item#7:(title)

    "Harlow's Kitchen & Craft Bar"

    you've ommitted the property-name(title)

  • item#31:(description)

    until "The Past Memories" becomes

    the double-quotes must be encoded

    until &quot;The Past Memories&quot; becomes

You may use http://jsonlint.com/ to validate a JSON-string

Your browsers debugger also should have reported these errors

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.