O'Reilly logo

HTML5 Data and Services Cookbook by Mite Mitreski, Gorgi Kosev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Showing a map with a path

When displaying maps, sometimes we may want to show more than just locations. Besides markers, the other most common map overlays are paths and areas.

In this recipe, we're going to create a map showing a path and an area.

How to do it...

Let's write the HTML and JavaScript code.

  1. Like in the Showing a map with a marked location recipe, we'll need to include the appropriate CSS and scripts. The following is an example HTML file:
    <!DOCTYPE HTML> <html> <head> <title>Map example</title> <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4/leaflet.css" /> <!--[if lte IE 8]> <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4/leaflet.ie.css" /> <![endif]--> </head> <body> <div id="map" style="height:480px; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required