{"id":380,"date":"2013-09-25T10:32:48","date_gmt":"2013-09-25T10:32:48","guid":{"rendered":"http:\/\/www.lincoln.ac.nz\/conversation\/gis\/?p=380"},"modified":"2023-05-07T04:17:05","modified_gmt":"2023-05-07T04:17:05","slug":"anatomy-of-a-web-map","status":"publish","type":"post","link":"https:\/\/blogs.lincoln.ac.nz\/gis\/anatomy-of-a-web-map\/","title":{"rendered":"Anatomy of a Web Map"},"content":{"rendered":"<p><em>In this post, we&#8217;ll have a closer look behind how web maps combine map services with web pages.<\/em><\/p>\n<p>In an earlier post we looked at some of the<a title=\"Our (Web) Maps\" href=\"http:\/\/blogs.lincoln.ac.nz\/gis\/our-web-maps\/\" target=\"_blank\" rel=\"noopener\"> web maps working off of our GIS server<\/a>. \u00a0In this post, we&#8217;ll have a closer look at just how web maps work. \u00a0We&#8217;ll use the staff\/student addresses web map we saw in the other post and dissect it to get a better idea of how it works. \u00a0We&#8217;re about to start looking at some code.<\/p>\n<p><em><strong><a href=\"http:\/\/www.phrases.org.uk\/meanings\/abandon-hope-all-ye-who-enter-here.html\" target=\"_blank\" rel=\"noopener\">All hope abandon, ye who enter here<\/a>&#8230;<\/strong><\/em><\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/abandon-all-hope-ye-who-enter-here.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-952\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/abandon-all-hope-ye-who-enter-here.jpg\" alt=\"abandon-all-hope-ye-who-enter-here\" width=\"295\" height=\"239\" \/><\/a><\/p>\n<p>So when we open up a web map in a browser, the map, like any webpage, is using some sort of code in the back room to make it display as you see it. \u00a0Usually this is HTML which most of us are at least a little bit familiar with. \u00a0Another type of code used in webpages is called <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Guide\/JavaScript_Overview\" target=\"_blank\" rel=\"noopener\">JavaScript<\/a>, \u00a0and often you have a combination of both. \u00a0As a start, let&#8217;s look at the <a href=\"http:\/\/gis.lincoln.ac.nz\/Addresses.htm\" target=\"_blank\" rel=\"noopener\">staff\/student addresses map<\/a> again:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/AddressWebMap.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-958\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/AddressWebMap.jpg\" alt=\"AddressWebMap\" width=\"1358\" height=\"712\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/AddressWebMap.jpg 1358w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/AddressWebMap-300x157.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/AddressWebMap-1024x537.jpg 1024w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/AddressWebMap-768x403.jpg 768w\" sizes=\"auto, (max-width: 1358px) 100vw, 1358px\" \/><\/a><\/p>\n<p>A combination of HTML and JavaScript give the page its look and feel. \u00a0In the great scheme of things it&#8217;s a very simple map with a few key elements: the map itself, which sits in its own pane and a simple legend on the right. \u00a0Map-wise there are several layers visible; the address points, suburb boundaries, a base map, and when zoomed in, bus lines and bus stops. \u00a0Not a lot of bells and whistles and a good one to start with for just those reasons.<\/p>\n<p>This web map began its life as an ArcMap map. \u00a0All it consists of are two layers: points to show address positions, symbolised as either staff, or domestic\/international students, and a layer of suburbs:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/MapView.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-950\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/MapView.jpg\" alt=\"MapView\" width=\"840\" height=\"485\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/MapView.jpg 840w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/MapView-300x173.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/MapView-768x443.jpg 768w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><\/a><\/p>\n<p>Once this was set up, the next step was to create a map service from this. \u00a0In ArcMap this is done from File &gt; Share As&#8230; &gt; Map Service. \u00a0This requires a connection to the GIS server, where a wizard takes us through the steps of starting a service (this process will be the subject of another post.) \u00a0 Once created on the server, the map service is now available on the web for anyone who knows where it is and how to use it. \u00a0Here I&#8217;ve called the map service &#8220;LUAddresses&#8221;. \u00a0I can get some information on the map service itself by looking\u00a0<a href=\"http:\/\/gis.lincoln.ac.nz\/arcgis\/rest\/services\" target=\"_blank\" rel=\"noopener\">here<\/a>:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/ServicesDir.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-951\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/ServicesDir.jpg\" alt=\"ServicesDir\" width=\"857\" height=\"624\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/ServicesDir.jpg 857w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/ServicesDir-300x218.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/ServicesDir-768x559.jpg 768w\" sizes=\"auto, (max-width: 857px) 100vw, 857px\" \/><\/a><\/p>\n<p>I saved the map service to the Maps folder and you can see it listed <a href=\"http:\/\/gis.lincoln.ac.nz\/arcgis\/rest\/services\/Maps\" target=\"_blank\" rel=\"noopener\">here <\/a>along with the other map services in that folder:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/MapServices.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-949\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/MapServices.jpg\" alt=\"MapServices\" width=\"838\" height=\"754\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/MapServices.jpg 838w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/MapServices-300x270.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/MapServices-768x691.jpg 768w\" sizes=\"auto, (max-width: 838px) 100vw, 838px\" \/><\/a><\/p>\n<p>Clicking on the link for the <a href=\"http:\/\/gis.lincoln.ac.nz\/arcgis\/rest\/services\/Maps\/LUAddresses\/MapServer\" target=\"_blank\" rel=\"noopener\">LUAddresses Service<\/a>, we get:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/LUAddressService.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-948\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/LUAddressService.jpg\" alt=\"LUAddressService\" width=\"751\" height=\"733\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/LUAddressService.jpg 751w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/LUAddressService-300x293.jpg 300w\" sizes=\"auto, (max-width: 751px) 100vw, 751px\" \/><\/a><\/p>\n<p>More gibberish, you may well say, but there&#8217;s some sense to be made here. \u00a0Under &#8220;Layers&#8221; there are two entries: 2012 Locations and Suburbs. \u00a0These correspond to the \u00a0layers from my original map. \u00a0One of the most important aspects of this page \u00a0is the URL in the address line of your browser, specifically:\u00a0<a href=\"http:\/\/gis.lincoln.ac.nz\/arcgis\/rest\/services\/Maps\/LUAddresses\/MapServer\" target=\"_blank\" rel=\"noopener\">http:\/\/gis.lincoln.ac.nz\/arcgis\/rest\/services\/Maps\/LUAddresses\/MapServer<\/a>. \u00a0We will need to know this when we write the web map&#8217;s script. \u00a0It&#8217;s literally the address of the map service. \u00a0Across the top you could click on one of the &#8220;View in&#8221; options to see what the map service <a href=\"http:\/\/gis.lincoln.ac.nz\/arcgis\/rest\/services\/Maps\/LUAddresses\/MapServer?f=jsapi\" target=\"_blank\" rel=\"noopener\">looks like<\/a> (below I&#8217;ve clicked the JavaScript option):<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/JavascirptMap.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-947\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/JavascirptMap.jpg\" alt=\"JavascirptMap\" width=\"1273\" height=\"677\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/JavascirptMap.jpg 1273w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/JavascirptMap-300x160.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/JavascirptMap-1024x545.jpg 1024w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/JavascirptMap-768x408.jpg 768w\" sizes=\"auto, (max-width: 1273px) 100vw, 1273px\" \/><\/a><\/p>\n<p>Pretty much as before only this one is running directly off the server rather than in ArcMap &#8211; this is the raw material our web map will work with at a later stage.<\/p>\n<p>Now, how are the other map layers added in in our final web map (the basemap and the bus routes\/stops)?<\/p>\n<p>If you&#8217;ve got any hope still left, please abandon it now.<\/p>\n<p>Web pages blend map services together via scripts that display them in a browser. \u00a0If you&#8217;ve still got the LUAddresses web map open in a browser, right-click anywhere on the page and go to &#8220;<a href=\"http:\/\/gis.lincoln.ac.nz\/Addresses.htm\" target=\"_blank\" rel=\"noopener\">view page source<\/a>&#8221; (or something similar &#8211; you may be tempted to try &#8220;Translate to English&#8221; in Chrome instead&#8230;) \u00a0A new tab should open up with a lot more gobbeldy-gook &#8211; this is the behind-the-scenes script that instructs the browser on how to display the page (an excerpt below.)<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/PageSource.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-959\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/PageSource.jpg\" alt=\"PageSource\" width=\"1264\" height=\"710\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/PageSource.jpg 1264w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/PageSource-300x169.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/PageSource-1024x575.jpg 1024w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/PageSource-768x431.jpg 768w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/PageSource-1200x675.jpg 1200w\" sizes=\"auto, (max-width: 1264px) 100vw, 1264px\" \/><\/a><\/p>\n<p>There&#8217;s a lot to this and we&#8217;ll skip over much of it (for now&#8230;) \u00a0My aim here to dissect it enough so we get a sense of how it all fits together. \u00a0Those familiar with HTML will see some common things, but much of it is JavaScript. \u00a0You&#8217;ll see lots of tags, things like &#8220;&lt;title&gt;&#8221;. \u00a0The browser interprets those tags and does different things with them depending on what they are. \u00a0For instance, if you look at the title of the tab for this map, it&#8217;s &#8220;Map with legend&#8221; which is precisely the text you see in-between the &lt;title&gt;&lt;\/title&gt; tags. \u00a0These are instructions to the browser to treat what&#8217;s in-between the opening a closing tags a special way.<\/p>\n<p>The JavaScript on the page is a bit like a program that makes the webpage jump through various hoops. \u00a0Scroll down the pages of the source code and look for the &#8220;<strong>function init () {<\/strong>&#8221; portion. \u00a0This is where the map portion of the page is getting set up. \u00a0Here&#8217;s a snippet of it:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/Init.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-946\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/Init.jpg\" alt=\"Init\" width=\"1234\" height=\"574\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/Init.jpg 1234w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/Init-300x140.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/Init-1024x476.jpg 1024w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/Init-768x357.jpg 768w\" sizes=\"auto, (max-width: 1234px) 100vw, 1234px\" \/><\/a><\/p>\n<p>The portion highlighted in blue should look a bit familiar &#8211; it&#8217;s the URL to the LUAddresses map service on gis.lincoln.ac.nz. \u00a0This line tells the web page to go out, find this map service and assign it to a variable called &#8220;locations&#8221;. \u00a0At the bottom note the &#8220;map.addLayers&#8221; line &#8211; this explicitly adds the map service to the page. \u00a0Above the line where our local map service gets added, there&#8217;s one called &#8220;basemap&#8221; and points to another map service, this one residing on a server called services.arcgisonline.co.nz. \u00a0It&#8217;s looking for a map service called &#8220;newzealand&#8221; in the Generic folder. \u00a0This is a map service put up by Eagle Technology for anyone to use &#8211; I use it on a lot of my web maps because it saves me the trouble of having to set one up on my own and displays different levels of detail depending on the scale. \u00a0Click <a href=\"http:\/\/services.arcgisonline.co.nz\/arcgis\/rest\/\" target=\"_blank\" rel=\"noopener\">here<\/a> to see their services directory.<\/p>\n<p>There&#8217;s also a line that adds the Bus_Routes_Scheduled map service from the ECan web server to a variable called &#8220;busroutes&#8221; that gets added to the map along with the addresses a the bottom.<\/p>\n<p>Nestled in between is the code that adds in the legend. \u00a0At the bottom of the script is some more HTML which sets up the different dividers on the page, the two separate panes that hold the content.<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/Divs.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-945\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/Divs.jpg\" alt=\"Divs\" width=\"1186\" height=\"264\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/Divs.jpg 1186w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/Divs-300x67.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/Divs-1024x228.jpg 1024w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2013\/09\/Divs-768x171.jpg 768w\" sizes=\"auto, (max-width: 1186px) 100vw, 1186px\" \/><\/a><\/p>\n<p>Yikes. \u00a0I&#8217;m sure that was a bit painful. \u00a0There are still a few missing pieces to be covered here, but my intention has been to give you a sense of how web maps do their thing.<\/p>\n<p>A really important point you can take from this is that <span style=\"color: #000000\"><strong>knowing the URL of a map service, you can also add these services to an ArcMap map. <\/strong>We covered how to do this in an\u00a0<a title=\"Canterburymaps.govt.nz and Web Services\" href=\"http:\/\/blogs.lincoln.ac.nz\/gis\/canterburymaps-govt-nz-and-web-services\/\" target=\"_blank\" rel=\"noopener\">earlier post<\/a>. \u00a0You just need to know the server the map service lives on to connect. \u00a0You can then browse available services in the service directory (e.g. http:\/\/&lt;server_name&gt;\/arcgis\/rest\/services, so long as it&#8217;s an ArcGIS server. \u00a0There are some other protocols we&#8217;ll cover another time.)<\/span><\/p>\n<p>So we&#8217;ve made it to the ninth circle of GIS hell and can now happily crawl into the next hemisphere of Purgatory (i.e. school holidays). \u00a0Dante would be proud. \u00a0If you&#8217;ve made it to the end of this, <a href=\"mailto:crile.doscher@lincoln.ac.nz\">let me know<\/a> and I&#8217;ll shout you a Pixie Caramel.<\/p>\n<p>C<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, we&#8217;ll have a closer look behind how web maps combine map services with web pages. In an earlier post we looked at some of the web maps working off of our GIS server. \u00a0In this post, we&#8217;ll have a closer look at just how web maps work. \u00a0We&#8217;ll use the staff\/student addresses [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-380","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts\/380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/comments?post=380"}],"version-history":[{"count":1,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts\/380\/revisions"}],"predecessor-version":[{"id":4161,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts\/380\/revisions\/4161"}],"wp:attachment":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/media?parent=380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/categories?post=380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/tags?post=380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}