<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Spatial Horizons &#187; OpenLayers</title>
	<atom:link href="http://spatialhorizons.com/category/openlayers/feed/" rel="self" type="application/rss+xml" />
	<link>http://spatialhorizons.com</link>
	<description>Exploring Geographic Technologies</description>
	<lastBuildDate>Sat, 10 Mar 2012 01:43:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>OpenLayers Tutorial &#8211; Place a Marker</title>
		<link>http://spatialhorizons.com/2011/03/27/openlayers-place-a-marker/</link>
		<comments>http://spatialhorizons.com/2011/03/27/openlayers-place-a-marker/#comments</comments>
		<pubDate>Sun, 27 Mar 2011 14:50:45 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[OpenLayers]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://spatialhorizons.com/?p=282</guid>
		<description><![CDATA[This post continues our series of OpenLayers tutorials. If you are new to OpenLayers, review our basic map setup tutorial before continuing. A common task of any mapping application is to place a marker at a specified location. OpenLayers provides several options for doing this but we will focus on using a Marker. Our simple [...]]]></description>
			<content:encoded><![CDATA[<p class="moreinfo">This post continues our series of OpenLayers tutorials. If you are new to OpenLayers, review our <a href="http://spatialhorizons.com/2011/03/16/openlayers-basic-map-setup/">basic map setup tutorial</a> before continuing.</p>
<p>A common task of any mapping application is to place a marker at a specified location. OpenLayers provides several options for doing this but we will focus on using a <a href="http://dev.openlayers.org/docs/files/OpenLayers/Layer/Markers-js.html" target="_blank">Marker</a>.</p>
<p>Our simple example will allow a user to plot the location of various US cities on an OpenLayers map.  In order to accomplish this, we need to know the longitude (X) and latitude (Y) of each city.  We will use <a href="http://www.realestate3d.com/gps/uslatlongdegmin.htm" target="_blank">this list</a> of city coordinates to create a HTML &lt;select&gt; box.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">select</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jumpTo&quot;</span> <span style="color: #000066;">onchange</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jumpTo();&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;NA&quot;</span>&gt;</span>=== Select a City ===<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;-84.42,33.65&quot;</span>&gt;</span>Atlanta<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;-104.87,39.75&quot;</span>&gt;</span>Denver<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>  
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;-95.35,29.97&quot;</span>&gt;</span>Houston<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;-81.32,28.43&quot;</span>&gt;</span>Orlando<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span> 
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;-121.50,38.52&quot;</span>&gt;</span>Sacramento<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;-95.62,39.07&quot;</span>&gt;</span>Topeka<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span> 
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">select</span>&gt;</span></pre></div></div>

<p><span id="more-282"></span><br />
Each &lt;option&gt; uses the value attribute to store the city&#8217;s coordinates. Note that the longitude coordinate is listed first and uses a negative number because we are in the western hemisphere.</p>
<p><img src="http://spatialhorizons.com/wp-content/uploads/2007/02/latlon_map.jpg" /></p>
<p>We also added a javascript function call <em>jumpTo</em> that is called when the selected value is changed.  This is where we will use OpenLayers to place a marker on the map.</p>
<p>Our OpenLayers map will be a single HTML page that is based on our <a href="http://spatialhorizons.com/2011/03/16/openlayers-basic-map-setup/">basic map setup tutorial</a>.  We next need to add a variable to track the markers.  This will be placed in the &lt;head&gt; along with some basic OpenLayers initialization code.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #003366; font-weight: bold;">var</span> map<span style="color: #339933;">,</span> baseLayer<span style="color: #339933;">,</span> markers<span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        map <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Map</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'map'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>            
        baseLayer <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Layer</span>.<span style="color: #660066;">WMS</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;OpenLayers VMAP0&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;http://labs.metacarta.com/wms/vmap0&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>layers<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;basic&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        map.<span style="color: #660066;">addLayer</span><span style="color: #009900;">&#40;</span>baseLayer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        map.<span style="color: #660066;">setCenter</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">LonLat</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #CC0000;">98</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">39</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        markers <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Layer</span>.<span style="color: #660066;">Markers</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Cities&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   			
        map.<span style="color: #660066;">addLayer</span><span style="color: #009900;">&#40;</span>markers<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>            
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Within the <em>init()</em> function, the markers layer is added to the map.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">markers <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Layer</span>.<span style="color: #660066;">Markers</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Cities&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   			
map.<span style="color: #660066;">addLayer</span><span style="color: #009900;">&#40;</span>markers<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Below that we need to add the <em>jumpTo()</em> function to place a marker on the selected city.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> jumpTo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    markers.<span style="color: #660066;">clearMarkers</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                
    <span style="color: #003366; font-weight: bold;">var</span> selectBox <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'jumpTo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>        		
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>selectBox.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;NA&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> parse <span style="color: #339933;">=</span> selectBox.<span style="color: #660066;">value</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">','</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> location <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">LonLat</span><span style="color: #009900;">&#40;</span>parse<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>parse<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 			
    <span style="color: #003366; font-weight: bold;">var</span> size <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Size</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">21</span><span style="color: #339933;">,</span><span style="color: #CC0000;">25</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> offset <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Pixel</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>size.<span style="color: #660066;">w</span><span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span>size.<span style="color: #660066;">h</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> icon <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Icon</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'http://www.openlayers.org/dev/img/marker.png'</span><span style="color: #339933;">,</span>size<span style="color: #339933;">,</span>offset<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    markers.<span style="color: #660066;">addMarker</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Marker</span><span style="color: #009900;">&#40;</span>location<span style="color: #339933;">,</span>icon.<span style="color: #660066;">clone</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>               			
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>The code first accesses the select box and makes sure the user selected a city.  It next collects the coordinates and parses them based on the comma in between.  It then creates a <a href="http://dev.openlayers.org/docs/files/OpenLayers/BaseTypes/LonLat-js.html">LonLat</a> object based on the parsed coordinates.</p>
<p>The next three lines define the marker&#8217;s icon and ensures that the marker point is placed exactly on the location (this code comes from the <a href="http://openlayers.org/dev/examples/markers.html">OpenLayers marker example</a>).  OpenLayers has markers in several colors which you can view <a href="http://www.openlayers.org/dev/img/" target="_blank">here</a>.  All of them are 21&#215;25 pixels in size but if you were to use your own image, be sure to change the <em>size</em> definition in the code.</p>
<p>The entire HTML code should look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>OpenLayers Tutorial - Place a Marker<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://openlayers.org/api/OpenLayers.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
        var map, baseLayer, markers;
        function init(){
            map = new OpenLayers.Map('map');            
            baseLayer = new OpenLayers.Layer.WMS(&quot;OpenLayers VMAP0&quot;, &quot;http://labs.metacarta.com/wms/vmap0&quot;, {layers:&quot;basic&quot;});
            map.addLayer(baseLayer);
            map.setCenter(new OpenLayers.LonLat(-98, 39),3); 
   	    markers = new OpenLayers.Layer.Markers(&quot;Cities&quot;);   			
            map.addLayer(markers);            
        }
&nbsp;
        function jumpTo()
        {
            markers.clearMarkers();        	
            var selectBox = document.getElementById('jumpTo');        		
   	    if (selectBox.value == &quot;NA&quot;) return;
   	    var parse = selectBox.value.split(',');
   	    var location = new OpenLayers.LonLat(parse[0],parse[1]); 			
   	    var size = new OpenLayers.Size(21,25);
            var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
            var icon = new OpenLayers.Icon('http://www.openlayers.org/dev/img/marker.png',size,offset);   
            markers.addMarker(new OpenLayers.Marker(location,icon.clone()));               			 
          }
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">style</span>&gt;</span>
    @media screen
    {
        #map{width: 500px; height:300px; border: 2px solid black;}
    }
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span> <span style="color: #000066;">onload</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;init()&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>OpenLayers Tutorial - Place a Marker<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;map&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span>&gt;</span>Place a marker at this city: <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">select</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jumpTo&quot;</span> <span style="color: #000066;">onchange</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jumpTo();&quot;</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;NA&quot;</span>&gt;</span>=== Select a City ===<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;-84.42,33.65&quot;</span>&gt;</span>Atlanta<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;-104.87,39.75&quot;</span>&gt;</span>Denver<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>  
    	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;-95.35,29.97&quot;</span>&gt;</span>Houston<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;-81.32,28.43&quot;</span>&gt;</span>Orlando<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span> 
    	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;-121.50,38.52&quot;</span>&gt;</span>Sacramento<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;-95.62,39.07&quot;</span>&gt;</span>Topeka<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span> 
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">select</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>Opening the web page should produce something like this:</p>
<div id="map"></div>
<p>
    <label>Place a marker at this city: </label><br />
<select id="jumpTo" onchange="jumpTo();" style="width:150px;">
<option value="NA">=== Select a City ===</option>
<option value="-84.42,33.65">Atlanta</option>
<option value="-104.87,39.75">Denver</option>
<option value="-95.35,29.97">Houston</option>
<option value="-81.32,28.43">Orlando</option>
<option value="-121.50,38.52">Sacramento</option>
<option value="-95.62,39.07">Topeka</option>
</select>
<h3><a href="http://spatialhorizons.com/examples/openlayers/place-a-marker.html">Click here to view the final result in a new window</a></h3>
]]></content:encoded>
			<wfw:commentRss>http://spatialhorizons.com/2011/03/27/openlayers-place-a-marker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenLayers Tutorial &#8211; Basic Map Setup</title>
		<link>http://spatialhorizons.com/2011/03/16/openlayers-basic-map-setup/</link>
		<comments>http://spatialhorizons.com/2011/03/16/openlayers-basic-map-setup/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 12:11:16 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[OpenLayers]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://spatialhorizons.com/?p=233</guid>
		<description><![CDATA[OpenLayers is a open source, javascript framework for generating dynamic maps. It&#8217;s incredibly powerful once you understand how to use it. But before we can tackle the more advanced applications, we need to lay some groundwork. This tutorial provides the basic code (HTML, CSS and JavaScript) needed to understand how to embed an OpenLayers map [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://openlayers.org/" target="_blank">OpenLayers</a> is a open source, javascript framework for generating dynamic maps. It&#8217;s incredibly powerful once you understand how to use it. But before we can tackle the more advanced applications, we need to lay some groundwork. This tutorial provides the basic code (HTML, CSS and JavaScript) needed to understand how to embed an OpenLayers map in a website.</p>
<h3>HTML Page Creation</h3>
<p>Create a new html file using your favorite text editor.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>OpenLayers Tutorial - Basic Map Setup<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">style</span>&gt;</span>
    @media screen{}
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>OpenLayers Tutorial - Basic Map Setup<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>  
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p><span id="more-233"></span></p>
<h3>Reference OpenLayers Javascript</h3>
<p>OpenLayers is provided in a single JavaScript file that you can reference remotely or download to a local machine. Let&#8217;s keep it simple and just reference the freely available version online.  Add this line inside the &lt;head&gt; portion of the file.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://openlayers.org/api/OpenLayers.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<h3>Initialize OpenLayers</h3>
<p>Inside &lt;head&gt;, we need to define several variables and create an initializing function.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
        <span style="color: #003366; font-weight: bold;">var</span> map<span style="color: #339933;">,</span> baseLayer<span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            map <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Map</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'map'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>            
            baseLayer <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Layer</span>.<span style="color: #660066;">WMS</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;OpenLayers WMS&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;http://labs.metacarta.com/wms/vmap0&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>layers<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;basic&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            map.<span style="color: #660066;">addLayer</span><span style="color: #009900;">&#40;</span>baseLayer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    
            map.<span style="color: #660066;">setCenter</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">LonLat</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>         
        <span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Inside the init function, the map will be created first. Then a WMS layer is defined using an existing map server. See <a href="http://en.wikipedia.org/wiki/Web_Map_Service">Wikipedia</a> for more information on WMS. In short, the WMS server in this example provides <a href="http://spatialhorizons.com/2007/07/15/map-tiles-1-introduction/">map tiles</a> of the world upon request. Fortunately, OpenLayers does this behind the scenes and no additional coding is needed. Lastly, the layer is added to the map and the map is centered on zero degrees longitude and latitude.</p>
<p>Call the initialize function from the onload event of the &lt;body&gt;.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span> <span style="color: #000066;">onload</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;init()&quot;</span>&gt;</span></pre></div></div>

<h3>Define the Map</h3>
<p>The next step is to add a &lt;div&gt; inside the &lt;body&gt; to serve as the container for the map. Most web programmers are already familiar with the broad uses of &lt;div&gt;&#8217;s and in the case of OpenLayers, it makes a perfect &#8220;map&#8221; representative.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;map&quot;</span> &gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p>The size of the map can now be defined using CSS.  In the &lt;head&gt; portion, add some variation of the following style.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"> &lt;style<span style="color: #00AA00;">&gt;</span>
    <span style="color: #a1a100;">@media screen</span>
    <span style="color: #00AA00;">&#123;</span>
        <span style="color: #cc00cc;">#map</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">500px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">250px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #000000; font-weight: bold;">black</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
    <span style="color: #00AA00;">&#125;</span>
 &lt;/style<span style="color: #00AA00;">&gt;</span></pre></div></div>

<h3>Full Source Code</h3>
<p>Your final HTML page should look something like this.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>OpenLayers Tutorial - Basic Map Setup<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://openlayers.org/api/OpenLayers.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
        var map, baseLayer;
        function init(){
            map = new OpenLayers.Map('map');            
            baseLayer = new OpenLayers.Layer.WMS(&quot;OpenLayers WMS&quot;, &quot;http://labs.metacarta.com/wms/vmap0&quot;, {layers:&quot;basic&quot;});
            map.addLayer(baseLayer);
            map.setCenter(new OpenLayers.LonLat(0,0),1);             
        }
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">style</span>&gt;</span>
    @media screen
    {
        #map{width: 500px; height:250px; border: 2px solid black;}
    }
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span> <span style="color: #000066;">onload</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;init()&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h3</span>&gt;</span>OpenLayers Tutorial - Basic Map Setup<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h3</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;map&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<h3>Working Demo</h3>
<p>Open the file in a web browser and the map should look like this:</p>
<div id="map"></div>
<p><strong><a href="http://spatialhorizons.com/examples/openlayers/basic-map-setup.html" target="_blank">Click here to view the final result in a new window</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://spatialhorizons.com/2011/03/16/openlayers-basic-map-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenLayers Tutorial &#8211; Add MapServer Data</title>
		<link>http://spatialhorizons.com/2007/12/16/openlayers-1-10-minute-tutorial/</link>
		<comments>http://spatialhorizons.com/2007/12/16/openlayers-1-10-minute-tutorial/#comments</comments>
		<pubDate>Sun, 16 Dec 2007 15:08:51 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[OpenLayers]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://spatialhorizons.com/2007/12/16/openlayers-1-10-minute-tutorial/</guid>
		<description><![CDATA[Update: This post was originally written in 2007. Please visit our newer OpenLayers Tutorials for more up-to-date information. This post introduces OpenLayers as a easy way to embed dynamic maps in a web page. First-time visitors are encouraged to read our previous posts on setting up MapServer and CGI MapServer for background information. OpenLayers is [...]]]></description>
			<content:encoded><![CDATA[<p class="moreinfo"><strong>Update:</strong> This post was originally written in 2007. Please visit our newer <a href="http://spatialhorizons.com/openlayers-tutorials/">OpenLayers Tutorials</a> for more up-to-date information.</p>
<p></p>
<p>This post introduces <a href="http://www.openlayers.org/">OpenLayers</a> as a easy way to embed dynamic maps in a web page. First-time visitors are encouraged to read our previous posts on <a href="http://spatialhorizons.com/2007/05/19/mapserver-1-10-minute-tutorial/">setting up MapServer</a> and <a href="http://spatialhorizons.com/2007/12/09/using-mapserver-3-cgi-mapserver/">CGI MapServer</a> for background information.</p>
<p>OpenLayers is a javascript library for creating maps on a web page. In their own words,</p>
<p class="shquote">OpenLayers is a pure JavaScript library for displaying map data in most modern web browsers, with no server-side dependencies. OpenLayers implements a (still-developing) JavaScript API for building rich web-based geographic applications, similar to the Google Maps and MSN Virtual Earth APIs, with one important difference &#8212; OpenLayers is Free Software, developed for and by the Open Source software community. &#8211; <a href="http://www.openlayers.org/">http://www.openlayers.org/</a></p>
<p>Setting up OpenLayers is incredibly easy if you want to display data from other existing sources on the web. See their <a href="http://www.openlayers.org/QuickTutorial/">Quick Tutorial</a> page for lots of sample HTML showing how to add a basic map in a web page.  In this tutorial, we will focus on how to create a map that uses our own data from MapServer.<br />
<span id="more-62"></span><br />
<strong>Tutorial Requirements</strong></p>
<p>Before beginning, you should already have MapServer setup on your computer. See our <a href="http://spatialhorizons.com/2007/05/19/mapserver-1-10-minute-tutorial/">previous post</a> to complete this task using the <a href="http://www.maptools.org/ms4w/">MS4W package</a>. Additionally, we will use GIS data and a MapServer mapfile from our <a href="http://spatialhorizons.com/2007/12/09/sample-dataset-world-map/">World Map sample dataset</a>.</p>
<p><strong>Download a Web Page from OpenLayers.org</strong></p>
<p>OpenLayers.org has a great <a href="http://openlayers.org/presentations/mappingyourdata/">screencast tutorial </a> showing how to setup and use OpenLayers. Accompanying the tutorial is a <a href="http://trac.openlayers.org/wiki/MappingYourData">wiki page</a> describing the steps covered in the video.  At the bottom of this page is a link to download an HTML document named lite.html that contains a good starting point for our tutorial.</p>
<p>Go ahead and download the file (<a href="http://trac.openlayers.org/attachment/wiki/MappingYourData/lite.html">direct link here</a>) to your desktop and open it in your favorite text editor. On line 10, note the reference to OpenLayers javascript file:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://openlayers.org/dev/lib/OpenLayers.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p><strong>Update:</strong> You can now reference OpenLayers using this location:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">   <span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://openlayers.org/api/OpenLayers.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Further down, lines 13 through 20 contain the all the javascript code necessary to embed a MapServer map in the web page:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> map<span style="color: #339933;">,</span> layer<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   map <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Map</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'map'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   layer <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Layer</span>.<span style="color: #660066;">MapServer</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;OpenLayers WMS&quot;</span><span style="color: #339933;">,</span>
       <span style="color: #3366CC;">&quot;http://labs.metacarta.com/wms/vmap0&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>layers<span style="color: #339933;">:</span> <span style="color: #3366CC;">'basic'</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   map.<span style="color: #660066;">addLayer</span><span style="color: #009900;">&#40;</span>layer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   map.<span style="color: #660066;">zoomToMaxExtent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>&nbsp;</p>
<p>In fact, without changing anything, you could open the web page in a browser and it will work fine because the data is coming from a remote server. The controls in the upper-left corner can be used to navigate around the map.</p>
<p><img src="http://spatialhorizons.com/wp-content/uploads/2007/12/openlayers_default.jpg" alt="&lt;br /&gt; OpenLayers" /></p>
<p><strong>Customizing the Javascript</strong></p>
<p>In order for the web page to display our own MapServer data, several changes need to be made to the Javascript in HTML file.</p>
<p>On line 17, the layer is initialized using the <a href="http://dev.openlayers.org/apidocs/files/OpenLayers/Layer/MapServer-js.html">OpenLayers.Layer.MapServer</a> class. Several parameters are required for the layer to work correctly. In the default example, the layer is named OpenLayers WMS (<a href="http://en.wikipedia.org/wiki/Web_map_server">Web Map Server</a>) and the MapServer location is http://labs.metacarta.com/wms/vmap0. The third parameter is informing the server to request the &#8220;basic&#8221; layer.</p>
<p>For our demonstration, we need to change the three parameters. First we will change the name to World Map. Next, we need to change the location to point to MapServer running on our local machine. Remembering our <a href="http://spatialhorizons.com/2007/12/09/using-mapserver-3-cgi-mapserver/">last post</a> on CGI MapServer, we already know that the path is <strong>http://localhost/cgi-bin/mapserv.exe</strong>. And finally, instead of requesting a layer name, we can just provide a file path to a mapfile. The final result looks like this:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> map<span style="color: #339933;">,</span> layer<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    map <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Map</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'map'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    layer <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">Layer</span>.<span style="color: #660066;">MapServer</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;World Map&quot;</span><span style="color: #339933;">,</span>
       <span style="color: #3366CC;">&quot;http://localhost/cgi-bin/mapserv.exe&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>map<span style="color: #339933;">:</span> <span style="color: #3366CC;">'C:/world_mapfile.map'</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    map.<span style="color: #660066;">addLayer</span><span style="color: #009900;">&#40;</span>layer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    map.<span style="color: #660066;">zoomToMaxExtent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>&nbsp;</p>
<p>Save the file and open lite.html in a web browser. The map should now display your data described in the mapfile.</p>
<p><img src="http://spatialhorizons.com/wp-content/uploads/2007/12/openlayers_map1.jpg" alt="OpenLayers Map" /></p>
<p><strong>More to Come</strong></p>
<p>OpenLayers offers a wide range of functionality that can be added our simple example.  For a list of examples, see <a href="http://trac.openlayers.org/wiki/UserRecipes">here</a>.</p>
<p>Also, visit our new <a href="http://spatialhorizons.com/openlayers-tutorials/">OpenLayers tutorials</a> for more information.</p>
]]></content:encoded>
			<wfw:commentRss>http://spatialhorizons.com/2007/12/16/openlayers-1-10-minute-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

