Spicy Grill<\/a> (Rating: 4)<\/small><\/h3>"
"122 Golders Green Road, London NW11 8HB<\/p>"
"Starters: \u00a33.00-\u00a37.50
Mains: \u00a39.50-\u00a313.50<\/small>"
},
"geometry": {
"type": "Point",
"coordinates": [-0.2007587,51.5739245]
}
},
…
];
I then use a JavaScript library called Leaflet, a library that I've used many
times for many of my other side projects to render these restaurants on the
map. The code for this is fairly simple too.
The ``id="map"`` div is where Leaflet renders the map, which you create in
JavaScript with::
I then configure the `OpenStreetMap `_ map layer
URL, attribution, and some configuration options for Leaflet::
Finally I add the map to the div element ``map`` by instantiating ``L.Map``,
and prevent zoom controls from showing::
var map = new L.Map('map', {zoomControl: false});
To see the full code, you can do "view source" on the `page that shows our
mapped restaurants `_.
When you click on an icon, you get a pop up with the title and a link to the
review, with some useful information such as our rating, the address, and a
cost indication:
.. image:: images/mapping-munchies.jpg
This actually didn't take me a lot of time to do, but mostly because I'm always
relatively familiar with Leaflet.
I enjoyed working on this project to add a map to the website.
And when `I now look at it `_, I can
see all the lovely places, and sometimes less lovely places where we had our
Friday night dinners. If you zoom out far enough, you can also see the far
away places we enjoyed our meals at. Let us know if you make it to one of
them!