Friday, January 29, 2010
Google
Layer for using Google Maps data within OpenLayers. For API information, see the Google Layer API Docs. For an example of usage, see the Spherical Mercator example.If you are overlaying other data on a Google Maps base layer, you will want to be interacting with the Google Maps layer in projected coordinates. (This is important if you are working with imagery data especially.) You can read more about the ‘Spherical Mercator’ projection that Google Maps – and other commercial layers – use in the Spherical Mercator documentation.
The Google Layer class is designed to be used only as a base layer.
Raster Layers
Raster Layers
Raster Layers are imagery layers. These layers are typically in a fixed projection which can not be changed on the client side.Non Base Layers
Non Base Layers
Non base layers – sometimes called overlays – are the alternative to Base Layers. Multiple non-base layer can be enabled at a time. These layers do not control the zoom levels of the map, but can be enabled or disabled at certain scales by min/max scale/resolution parameters so that they are only enabled at a certain level.Some types of overlays support reprojection to the base layer projection at layer load time. Most overlay layers default to non-base overlays, as does the base Layer class. Non-base Layers always display above base layers.
Base Layers
Base Layers
Base Layers are mutually exclusive layers, meaning only one can be enabled at any given time. The currently active base layer determines the available projection (coordinate system) and zoom levels available on the map.Whether a layer is a base layer or not is determined by the isBaseLayer property on the layer. Most raster layers have the isBaseLayer property set to true by default. It can be changed in the layer options.
Base Layers always display below overlay layers.
Base Layers and Non-Base Layers
Base Layers and Non-Base Layers
OpenLayers has two types of layers when operating in your application: base layers and overlays. This difference controls several aspects of how you interact with an OpenLayers Map.Monday, January 18, 2010
Layer Constructor
var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0",
{'layers':'basic'} );
map.addLayer(wms);
Map Constructor
var map = new OpenLayers.Map('map');
Creating the Map Viewer
var map = new OpenLayers.Map('map');
The next step to creating a viewer is to add a layer to the Map. OpenLayers supports many different data sources, from WMS to Yahoo! Maps to WorldWind. In this example, the WMS layer is used. The WMS layer is an example provided by MetaCarta.
var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0",
{'layers':'basic'} );
map.addLayer(wms);
The first parameter in this constructor is the URL of the WMS server. The second argument is an object containing the parameterss to be appended to the WMS request.
Finally, in order to display the map, you must set a center and zoom level. In order to zoom to fit the map into the window, you can use the zoomToMaxExtent function, which will zoom as close as possible while still fitting the full extents within the window.
OpenLayers. Layer.WMS | Constructor
Example
var wms = new OpenLayers.Layer.WMS("NASA Global Mosaic", "http://wms.jpl.nasa.gov/wms.cgi", {layers: "modis,global_mosaic"});
Parameters
name | {String} A name for the layer |
url | {String} Base url for the WMS (e.g. http://wms.jpl.nasa.gov/wms.cgi) |
params | {Object} An object with key/value pairs representing the GetMap query string parameters and parameter values. |
options | {Ojbect} Hashtable of extra options to tag onto the layer |
Creating Your First Map
Openlayers Tutorials
Saturday, January 16, 2010
Installing Openlayers in Ubuntu
1) set Ubuntu sources needed for this software
Add universe ( http://archive.ubuntu.com/gutsy/universe ) and multiverse repositories to your sources (by default are not in Ubuntu)
sudo gedit /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu/ gutsy-security main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ gutsy-security main restricted universe multiverse
sudo apt-get update
2) Install MapServer
now download and install MapServer:
sudo apt-get install cgi-mapserver mapserver-bin mapserver-doc php5-mapscript python-mapscript
/usr/lib/cgi-bin/mapserv -v MapServer version 4.10.3 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=THREADS SUPPORTS=GEOS INPUT=EPPL7 INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE DEBUG=MSDEBUG
- mapserv is installed from cgi-mapserver package in /usr/lib/cgi-bin
- command line utilities (like shp2img) are installed by the mapserver-bin package in /usr/bin
- some documentations is installed by the mapserver-cod package in /usr/share/doc/mapserver-doc
3) Download MapServer Demo
Download the Mapserver 4.x Demo Application from the MapServer web site: http://maps.dnr.state.mn.us/mapserver_demos/workshop.zip
extract the zip file wherever you like, for example i have extracted it here: /home/corti/public_html/mapserverdemo
4) Configure Apache httpd
Configure an httpd virtual host for MapServer. For example we will create a mapserverdemo virtual host editing the default file
sudo gedit /etc/apache2/sites-available/default
*:80> ServerName mapserverdemo DocumentRoot /home/corti/public_html/mapserverdemo /> Options FollowSymLinks AllowOverride All > ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ "/usr/lib/cgi-bin"> AllowOverride None Options ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all > ErrorLog /var/log/apache2/mapserverdemo_error.log. LogLevel warn CustomLog /var/log/apache2/mapserver_access.log combined ServerSignature On >
sudo gedit /etc/hosts
127.0.0.1 mapserverdemo
save the file and restart Apache:
sudo /etc/init.d/apache2 restart
Now if you go to http://mapserverdemo/workshop/ you will see a form, but after that it will not work as far we need to add the html form settings to our settings.
If you go at: http://mapserverdemo/cgi-bin/mapserv you should get this response:
No query information to decode. QUERY_STRING is set, but empty.
Now let’s configure the demo with our settings.
Edit this section in index.html file (wherever you have extracted the demo), according to your settings:
<form name="demo" method="GET" action="/cgi-bin/mapserv" onSubmit="submit_form()"> ....... <input type="hidden" name="map" value="/home/corti/public_html/mapserverdemo/workshop/itasca.map"> <input type="hidden" name="program" value="/cgi-bin/mapserv"> <input type="hidden" name="root" value="/mapserver_demos/workshop"> <input type="hidden" name="map_web_imagepath" value="/home/corti/public_html/mapserverdemo/tmp/"> <input type="hidden" name="map_web_imageurl" value="/tmp/">
Installing Mapserver -Windows
We just need to setup MapServer to run on a local machine for now and the best way to do that is to use MapServer for Windows (MS4W). This package is a all-in-one web mapping environment. It comes complete with Apache Web Server, PHP, MapServer, and other open source GIS utilities. Here’s how to set it up and add a “Google Maps”-like interface (using ka-Map) in under 10 minutes . I won’t describe the details of how everything interacts because you don’t really have to know right now. It just works.
- Download the MS4W PHP5 Base Installer v2.2.6 (Sept 18,2007) from here.
- Unzip the file to the root of your C:\ drive and this will create a folder C:\ms4w.
- For some initial data, download the PHP/MapScript Sample Application here. The zip file is named gmap_ms4w_ms410.zip.
- Again, unzip this file at the root of your C:\ drive and it will automatically be placed into the folder C:\ms4w\apps\gmap.
- Download the ka-Map Javascript API from the same page. This file is named ka-map-ms4w-1.0.zip.
- Again, unzip this file to the root of your C:\ drive and it will automatically be placed into the folder C:\ms4w\apps\ka-map-1.0.
- Navigate to C:\ms4w and double-click on the file named apache-install.bat. In one-click, you’ve setup your web server and MapServer is ready to use.
- Open your web browser and goto http://localhost/. You should see an Introduction to MapServer 4 Windows page.
- Scroll to the bottom of the page and click the ka-Map Sample Interface link. This will load up the sample application we downloaded in step 3 using the ka-Map interface. The map should look like this:
Congratulations! You’ve just setup a mapping website. In short, ka-Map is basically a web page front-end for MapServer that is similar to Google Maps. MapServer is used to generate map images in the form of map tiles and ka-Map then presents them to the user so they can pan, zoom, identify, and search the map. More details to follow in later posts.
Introduction to MapServer
One of the most popular open source GIS applications is MapServer. Initially developed by the University of Minnesota, MapServer has evolved into a fast and easy-to-use internet map server.
“MapServer is an Open Source development environment for building spatially-enabled internet applications. MapServer is not a full-featured GIS system, nor does it aspire to be. Instead, MapServer excels at rendering spatial data (maps, images, and vector data) for the web.” – http://mapserver.gis.umn.edu/