{"id":23973,"date":"2023-07-10T08:37:05","date_gmt":"2023-07-10T08:37:05","guid":{"rendered":"https:\/\/www.highcharts.com\/blog\/?p=23973"},"modified":"2026-01-13T11:34:47","modified_gmt":"2026-01-13T11:34:47","slug":"map-highcharts-openstreetmap","status":"publish","type":"post","link":"https:\/\/www.highcharts.com\/blog\/tutorials\/map-highcharts-openstreetmap\/","title":{"rendered":"Create a map with Highcharts and OpenStreetMap"},"content":{"rendered":"<p>Creating a tiled web map with points of interest is a great way to represent data on a map visually. In this tutorial, I will guide you through the process of creating a Chinese tiled web map using Highcharts and <a href=\"https:\/\/www.openstreetmap.org\/\" target=\"_blank\" rel=\"noopener\">OpenStreetMap<\/a>. I will focus on showcasing the world heritage sites in China obtained from the unesco.org website. You can easily create your own interactive map by following these simple steps.<\/p>\n<p class=\"demo-container\">\n<iframe height=\"610\" style=\"width: 100%;\" scrolling=\"no\" title=\"World heritage sites in China\" src=\"https:\/\/codepen.io\/mushigh\/embed\/QWJOMPq?default-tab=result\" frameborder=\"no\" loading=\"lazy\" allowtransparency=\"true\" allowfullscreen=\"true\"><br \/>\n  See the Pen <a href=\"https:\/\/codepen.io\/mushigh\/pen\/QWJOMPq\"><br \/>\n  World heritage sites in China<\/a> by mustapha mekhatria (<a href=\"https:\/\/codepen.io\/mushigh\">@mushigh<\/a>)<br \/>\n  on <a href=\"https:\/\/codepen.io\">CodePen<\/a>.<br \/>\n<\/iframe>\n<\/p>\n<p>Let&#8217;s get started \ud83d\ude42<\/p>\n<p>The first step is to get the data. For this tutorial, I use the Chinese world heritage sites data I retrieved from the <a href=\"https:\/\/whc.unesco.org\/en\/list\/\" target=\"_blank\" rel=\"noopener\">unesco.org<\/a> website. The data should include the name, image, and geo-location of each world heritage site. Here is an example of code structure for a single location:<\/p>\n<pre>{\r\n  name: \"The Great Wall\",\r\n  image: \"https:\/\/whc.unesco.org\/uploads\/sites\/site_438.jpg\",\r\n  lon: 116.08333,\r\n  lat: 40.41667\r\n}<\/pre>\n<p>Then, I split the data into three layers on the map: cultural, natural, and mixed, based on the classification of the sites, where each dataset has its own color and marker. A red square marker for cultural sites, a green triangle for natural sites, and a blue circle for mixed sites. The data code section looks like this:<\/p>\n<pre>{\r\n  type: \"mappoint\",\r\n  name: \"Cultural\",\r\n  color: \"#DE3163\",\r\n  marker: {\r\n    symbol: \"square\"\r\n  },\r\n  data: [...]\r\n} {\r\n  type: \"mappoint\",\r\n  name: \"Natural\",\r\n  color: \"#088F8F\",\r\n  marker: {\r\n    symbol: \"triangle\"\r\n  },\r\n  data: [...]\r\n} {\r\n  type: \"mappoint\",\r\n  name: \"mixed\",\r\n  color: \"#0096FF\",\r\n  marker: {\r\n    symbol: \"circle\"\r\n  },\r\n  data: [...]\r\n}<\/pre>\n<p>To visualize the locations on a map, I use Highcharts Maps and the OpenStreetMap for the map tiles. This process is super easy since Highcharts Maps is doing all the work behind the scene, and all I have to do is to add the <code>tiledwebmap.js<\/code> module to my project and then include the following code snippet:<\/p>\n<pre>{\r\n   type: \"tiledwebmap\",\r\n   name: \"Basemap Tiles\",\r\n   provider: {\r\n     type: \"OpenStreetMap\"\r\n   },\r\n   showInLegend: false\r\n }<\/pre>\n<p>This code sets up the map type as tiledwebmap and OpenStreetMap as the provider.<\/p>\n<p>Now that the basic map is set up, it&#8217;s time to incorporate the data. Loop through each location in your dataset and add it to the map:<\/p>\n<pre>{\r\n  name: \"The Great Wall\",\r\n  image: \"https:\/\/whc.unesco.org\/uploads\/sites\/site_438.jpg\",\r\n  lon: 116.08333,\r\n  lat: 40.41667\r\n}, {\r\n  name: \"Imperial Palaces of the Ming and Qing Dynasties in Beijing and Shenyang\",\r\n  image: \"https:\/\/whc.unesco.org\/uploads\/sites\/site_439.jpg\",\r\n  lon: 123.4469444,\r\n  lat: 41.79416667\r\n}, {\r\n  name: \"Mogao Caves\",\r\n  image: \"https:\/\/whc.unesco.org\/uploads\/sites\/site_440.jpg\",\r\n  lon: 94.81667,\r\n  lat: 40.13333\r\n},<\/pre>\n<p>One important tip to add is to focus on a specific area, in this case, China, without clipping the map, regardless of the screen size. To do that, I use the magic option <code>fitToGeometry<\/code>:<\/p>\n<pre>const countryGeometry = geojson.features.find(\r\n  (f) => f.properties.name === \"China\"\r\n).geometry;\u2026\r\nmapView: {\r\n  fitToGeometry: countryGeometry\r\n},<\/pre>\n<p>Now, I am sure that the country of interest is always at the center of the screen.<\/p>\n<p>And that is it. Now, you know how to create a map using Highcharts and OpenStreetMap.<br \/>\nCreating a tiled web map with points of interest is an effective way to visualize data on a map. By combining Highcharts&#8217; maps features with the OpenStreetMap provider, you can easily create interactive maps showcasing world heritage sites or any other points of interest. <\/p>\n<p>\u00a0<\/p>\n<h2><strong>Related posts<\/strong><\/h2>\n<ul>\n<li style=\"margin-left: 20px; margin-bottom: 20px;\"><a href=\"https:\/\/www.highcharts.com\/blog\/inspirations\/javascript-data-visualization-with-highcharts\/\">JavaScript data visualization with Highcharts<\/a><\/li>\n<li style=\"margin-left: 20px; margin-bottom: 20px;\"><a href=\"https:\/\/www.highcharts.com\/blog\/inspirations\/javascript-graph-visualization-library-by-highcharts\/\">JavaScript graph visualization library by Highcharts<\/a><\/li>\n<li style=\"margin-left: 20px; margin-bottom: 20px;\"><a href=\"https:\/\/www.highcharts.com\/blog\/inspirations\/javascript-library-by-highcharts\/\">JavaScript library by Highcharts<\/a><\/li>\n<li style=\"margin-left: 20px; margin-bottom: 20px;\"><a href=\"https:\/\/www.highcharts.com\/blog\/inspirations\/javascript-map-library-by-highcharts\/\">JavaScript map library by Highcharts<\/a><\/li>\n<li style=\"margin-left: 20px; margin-bottom: 20px;\"><a href=\"https:\/\/www.highcharts.com\/blog\/inspirations\/javascript-maps-with-highcharts\/\">JavaScript maps with Highcharts<\/a><\/li>\n<li style=\"margin-left: 20px; margin-bottom: 20px;\"><a href=\"https:\/\/www.highcharts.com\/blog\/inspirations\/map-library-by-highcharts\/\">Map library by Highcharts<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to create a map using Highcharts and OpenStreetMap with ease.<\/p>\n","protected":false},"author":32,"featured_media":23979,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"meta_title":"","meta_description":"","hc_selected_options":[],"footnotes":""},"categories":[210],"tags":[876,1031],"coauthors":[699],"class_list":["post-23973","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-highcharts-maps","tag-javascript"],"_links":{"self":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts\/23973","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/users\/32"}],"replies":[{"embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/comments?post=23973"}],"version-history":[{"count":3,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts\/23973\/revisions"}],"predecessor-version":[{"id":26021,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts\/23973\/revisions\/26021"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/media\/23979"}],"wp:attachment":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/media?parent=23973"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/categories?post=23973"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/tags?post=23973"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/coauthors?post=23973"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}