Sei sulla pagina 1di 12

MapLab - tutorial

http://maps.unomaha.edu/Workshops/OpenSourceFiles/MapLab-tutorial.htm

MapLab 2.2 Getting Started Manual


DM Solutions Group Inc. Abstract This document is a mini-tutorial on using MapLab 2.2 and all of its components. Please forward questions to the MapLab user list. Last updated: 2004/07/17 Table of Contents Introduction MapLab MapEdit MapEdit's Work Area Opening/Importing a Mapfile Previewing a Mapfile Saving a Mapfile Modifying the Map Object Modifying Layer Objects About Layer Objects Removing Layer Objects Adding Layer Objects (with Raster Data) Adding Layer Objects (with Vector Data) Adding Class Objects Adding Style Objects Selecting the ClassItem field Adding Labels to a Class Object MapBrowser MapBrowser's Work Area Opening a Mapfile Exploring MapBrowser Adding a Layer Adding a Projection Object Adding a Layer When the Projection has been Set GMapFactory Creating a Project File Creating Your Application

Introduction
This document describes how to use MapLab, an open source tool for the creation of Web-mapping applications. MapLab is comprised of three components (MapEdit, MapBrowser and GMapFactory) and offers a user-friendly alternative to manually editing mapfiles and programming PHP mapscript in the creation of MapServer applications. Note: MapLab 2.2 works with MapServer version 4.0 - while mapfiles from earlier version can be accessed, all mapfiles are saved in MapServer 4.0 format. This document assumes that you are a novice user of PHP MapScript and MapLab, but have familiarity with HTML code or Web creation, as well as some GIS terminology. This document also assumes that MapLab is installed in the following directory: c:\ms4w\apps. Finally, this document assumes that you are using Internet Explorer as your browser. If you are using another browser certain functions may not appear as described in this document. This document is arranged as a tutorial and will take you through each application (MapEdit, MapBrowser, GMapFactory) by using an already existing mapfile called tutorial.map. To have an understanding of what is involved in the creation of a MapServer application without the use of MapLab, you can navigate to c:\ms4w\apps\maplab-2.2\tutorial and open up the file tutorial.phtml in Notepad or TextPad.

MapLab
Once you have MapLab installed and configured you may go ahead and start Internet Explorer. Once your browser is opened, type in the following in the address bar: http://<server>/maplab/ and hit Enter on your keyboard. This will bring you to the MapLab introduction page. Here, you will see links to all three components of MapLab (MapEdit, MapBrowser and GMapFactory) and a description of what each one of them does. Read the descriptions. Look at the first four buttons on the toolbar (top left hand corner). These four buttons, known as MapLab MapBrowser program.) and GMapFactory , MapEdit ,

, are a means of navigating to the various programs. (You will find them in the upper left-hand corner in each

1 of 12

15/09/2011 9:38

MapLab - tutorial

http://maps.unomaha.edu/Workshops/OpenSourceFiles/MapLab-tutorial.htm

We will begin this tutorial by first exploring MapEdit. Click on the MapEdit heading or on the MapEdit button

in the toolbar.

MapEdit
MapEdit is a tool for creating, editing, and managing mapfiles.

MapEdit's Work Area


Let's start with a brief overview of the MapEdit work area. MapEdit is devised of three major parts: the Object Browser, the Object Properties Frame and the Toolbar. On the left-hand side is the area known as the Object Browser and it contains the features and map layers for the map (collectively called 'Objects' in the underlying mapfile). The right-hand side is known as the Object Properties Frame and it contains the information and the parameters for each of the Objects. Across the top of MapEdit is the Toolbar. The tool bar itself is divided into two parts: MapLab buttons and MapEdit buttons. The MapLab buttons will take you to the other programs in MapLab, such as GMapFactory and MapBrowser, or back to the MapLab main page. The MapEdit buttons are for performing functions specifically in MapEdit. Many of the buttons will be familiar to you, others will not. You will learn what most of these buttons do by the end! of the tutorial. You will notice that some of the buttons are greyed out, this means they are currently not available to you. These buttons will become available once we have a mapfile to work with.

Opening/Importing a Mapfile
MapEdit works with files called mapfiles which are the basic configuration mechanisms for MapServer. We are going to open an already existing

2 of 12

15/09/2011 9:38

MapLab - tutorial

http://maps.unomaha.edu/Workshops/OpenSourceFiles/MapLab-tutorial.htm

mapfile called tutorial.map to conduct this tutorial. Move your cursor to the File Menu dropdown , click on the down arrow, and select the Open Map ... option. The Open File window will appear. Navigate your way to the file tutorial.map, this is located at c:\ms4w \apps\maplab-2.2\tutorial\. Click on tutorial.map and then click on the Open button .

If you look in the Object Browser (the area on the left-hand side) you will see all the objects listed that make up this mapfile. Right now you are on the Map Object. You will know this because of two clues. The first clue is that the Map Object appears in a darker color in the Object Browser and the second clue is that you will see the name "Map" in the top left corner of the Object Properties Frame (the area on the right-hand side). The Map Object is responsible for defining the application-wide parameters, and is therefore a very important piece in building a mapfile. You can find out more information about the Map Object and the other objects in a mapfile by clicking on the Help button and going to Mapfile Reference v4.0. The Object Properties Frame contains all the information for building the Map Object, you will see several parameters listed in this frame! for the Map Object. Try clicking on the other Objects listed in the Object Browser to see what their parameters are. You can find out more information about what each of these parameters are by clicking on the Help button and going to the Mapfile reference v4.0. The Open Map ... option only allows you to access mapfiles written in v4.0 of MapServer. If you have mapfiles written in an earlier version of MapServer, you must use the Import 3.x Map ... option from the File Menu dropdown. Try importing the file tutorial36.map, which is also located at c:\ms4w\apps\maplab-2.2\tutorial\. A warning will appear telling you that certain formatting (e.g., comments) in your older file will be lost once it is saved again, and that it would be best for you to save a copy of the original file.

Previewing a Mapfile
Now that you have had a chance to explore the different Objects and their parameters that make up a mapfile, let's see what type of map it makes. 1. In the main toolbar click on the Preview map button . Another window will appear in your browser with a map of Canada. We will explore this map of Canada. 2. Go to the Legend and click on the empty box next to Grid so that a check mark appears. Now click on the Redraw Map button , which is at the bottom of the Legend. Lines of latitude and longitude will appear over the map. Experiment with turning on and off other layers in the legend. Remember to click on the Redraw button to view your changes.

3. Go to the ROSA applet (on the right-hand side of the map) and you will see various tools for exploring your map. These buttons can be turned on or off by clicking on them You will know that a button is on when it is a light blue color and it will be off when it is a dark blue color . By default the Zoom in button is always on when you first preview the map (so it is a light blue color). Since this button should be on (check to see if it is light blue) drag a rectangular box around the area you want to zoom in to and watch as your map reloads and zooms into that area.. Explore with the Recenter button to recenter the location of your map. Zoom out with the Zoom out button . . You can also zoom back to the full map size! by clicking on the Zoom to full extents button 4. Zoom into an area on the map of Canada. Go to the keymap

and you will see that a little red box outlines the area of Canada

that you are zoomed into. Click on an area of Canada on the keymap. What happens? You will notice that the main map moves with the location of the red box. 5. You may also want to experiment with the scale of the map. You can do this by going to the box titled map scale and change the number in that box. Smaller numbers will zoom you into the map, larger numbers will zoom you out of the map. 6. You can also experiment with changing the extents of the map. Adjust the numbers in the min x and y and the max x and y boxes to see how it affects the map. Remember you can always click on the Zoom to full extents button to bring you back to the defaults. 7. Close the window with the tutorial preview and return to MapEdit. Now that you know what the map looks like we are going to make a few changes.

Saving a Mapfile
The first change we are going to make is to save our mapfile under a different name. This way you will have a separate copy from the original. 1. Click on the File Menu dropdown and select the Save Map As ... option. Once the Save As window appears, navigate to c:\ms4w \apps\maplab-2.2\tutorial. You must save your mapfile in this directory as the mapfile uses relative paths. If you attempt to save your file in a different directory you will receive a JavaScript alert warning you to check SYMBOLSET, FONTSET and SHAPEPATH. If you choose to save the mapfile in a new directory you must change these paths.

3 of 12

15/09/2011 9:38

MapLab - tutorial

http://maps.unomaha.edu/Workshops/OpenSourceFiles/MapLab-tutorial.htm

2. Name this file mymap (no spaces). Now click on the Save button . 3. Now every time you wish to save your mapfile, you can click select the Save Map option from the File Menu dropdown.

Modifying the Map Object


We are going to make a few changes to the Map Object 1. Make sure that you are in the Map Object. You will know that you are, as it will appear in a darker color in the Object Browser than the other objects and the name "Map" will appear in the upper left-hand corner of the Object Properties Frame. 2. The first change we are going to make is to change the name of the map from Demo to something that better reflects our map. Go to the Name parameter and delete the name Demo and replace it with Map of Canada. This name will not appear on your map but it will better reflect what your map is about in the Object Browser. This may be important if other people are working on the same mapfile and want to quickly know what the map is about without having to preview it. 3. Let's also change the size of the map. Go to the parameter that says Size. In the width box delete the number 400 and change it 600 and in the height box change the height from 300 to 450. 4. Now, select the Save Map option from the File Menu dropdown. 5. To see what your changes have done, click on the Preview map button . You will notice that your map is no longer called tutorial but is now called mymap, the name you gave it when we re-saved the mapfile. You will also notice that the size of the map is significantly bigger. 6. Keep your preview of the map open. We are going to make changes to the map size on the fly and see what they look like before we save them. Change the size of the map to 1000 by 750 and click the Apply changes button . This button does not save your changes but allows you to see what your map will look like if you make changes to the mapfile. To see the changes, go to the map preview window and click the Redraw button at the bottom of the legend. 7. Close the preview. Since the size is obviously too large we are going to change the map back to 400 by 300. 8. Select Save Map. We will not worry about the following objects: Reference, Query map, Legend or Scalebar but you can read up on those objects by clicking on the Help button and going to Mapfile reference v4.0

Modifying Layer Objects


You will notice that there are several Layer objects in your Mapfile (bathymetry down to grid). Layer objects describe the layers used in the mapfile. If you preview your map and go to the legend, you will see everyone of your Layer objects in the legend. Layer objects are made up of GIS data, they can be either raster or vector data and can be made up of several data types including: ArcView shapefiles coverages, MapINFO Native and MID/MIF, Intergraph DGN, GIF, JPEG, PNG, TIFF/GeoTIFF, ERDAS, ArcSDE, Oracle SDO and PostGIS. About Layer Objects 1. Click on the bathymetry layer. You will know that you are on the bathymetry layer because it appears in a darker color than the other layers and the name "layer" will appear in the upper left-hand corner of the Object Properties Frame. 2. Have a look at the parameters for this object and you will notice that it is a .tif file and therefore it is a raster file as indicated in the Data type parameter. 3. You will also notice that underneath the bathymetry layer there is a Metadata Object. Click on it. The metadata describes the data, in this case it tells us that this data file provides information on bathymetry as well as elevation. You may also notice there are is a little x next to each of the fields in the metadata. The x is a way of deleting a field if you do not want it in your metadata. 4. Click on the popplace layer. This is vector data and we know from the Data type that it is a point file. Popplace also has a metadata Object, however, below this metadata Object are two Objects not contained under the bathymetry layer. These two Objects are called Class Objects; all vector data (like popplace) require at least one class Object. As bathymetry is raster data it does not require a class Object. Removing Layer Objects We are going to delete both of these layers to go through the process of adding both a raster and a vector layer into MapEdit. 1. Click on the popplace layer so it is selected. To ensure you have the popplace layer selected, look for the two clues that let you know which . Object you are on. Now click on the Remove Object button 2. Now remove the Bathymetry layer. Select Save Map from the File Menu dropdown. 3. Let's see what our map looks like without these two layers. Click on the Preview map button. You will notice that information about elevation and bathymetry are missing as well as the provincial capitals and national capital of Canada. You will also notice that bathymetry and popplace are missing from the legend. Adding Layer Objects (with Raster Data) We will now go through the process of adding the bathymetry layer back to our map. As you will remember, the bathymetry layer was made up of raster data.

4 of 12

15/09/2011 9:38

MapLab - tutorial

http://maps.unomaha.edu/Workshops/OpenSourceFiles/MapLab-tutorial.htm

1. Click on the Map Object in the Object Browser. Make sure you have the Map Object selected. 2. Use the drop down menu in the tool bar and change Create New Object to Layer Object. Click on the Add new item button new layer object. to add a

3. You will notice that a new layer appears at the bottom of the Object Browser, it is called layer(). We are going to use this layer to re-add the bathymetry layer. Click on it now. 4. The first step is to add the bathymetry file to the layer. Go to the parameter called Data and type bath_mapserver.tif. 5. Now, we must give this layer a name. This name will appear in the Object Browser as well as the Legend, so you will want to give layers name that accurately describe what they show. Go to the Name parameter and type in bathymetry in the empty field. 6. We must also say whether we want this file to be automatically on when someone visits the map, or whether we would like it off and have the users turn it on in the legend (remember the check mark?). We are going to make the bathymetry layer be automatically on. Go to the Status parameter and using the drop down menu, select On.

7. The next step is to describe what type of data this is. As mentioned previously, this is raster data, so go to the parameter named Type and using the drop down menu select Raster. 8. Select Save Map. 9. Let's have a look at your map now. Click on the Preview map button. You may notice that your bathymetry layer now covers all the other layers. This is because of two reasons, one is because the spatial coverage of the layer and the other is its placement in the Object Browser. Since the bathymetry layer covers all of Canada, it will hide some of the other smaller layers, therefore we need to place the layer so that the other layers overlay on top of it. Currently, our bathymetry layer is on top of all the others, hiding them. The reason for this is because when MapEdit builds our map it builds the objects from top to bottom as listed in the Object Browser, since the bathymetry layer is on the bottom, it gets built last, meaning it is the last layer to be placed on the map. 10. We need to move the bathymetry layer up so that it is the first layer listed in the Object Browser (i.e., above the land_fn layer). Click on the . You will notice that with one click it has moved up in the Object bathymetry layer to select it. Now click on the Promote Object button Browser. Keep clicking on the Promote Object button until it is above the land_fn layer (foreign land) and below the Scalebar Object. If you need to you can use the Demote Object button to move the bathymetry layer down. 11. Select Save Map. 12. Click on the Preview map button to see what the map looks like now that you have moved the bathymetry layer. You should see that the other layers are now visible. Close the Map Preview window. 13. The final step is to add metadata to our layer. Click on the bathymetry layer so that it is selected. Go to the toolbar and using the drop down menu change Create New Object to Metadata Object. Click on the New item button . You should see a metadata layer appear below the bathymetry layer. 14. Click on the metadata layer. We need to add some information to the metadata. To do this, use the drop down menu and change it to Add new metadata and click on the New item button. Under the heading parameter type Description and under the heading value type Elevation/Bathymetry. Now click on the Apply Changes button. 15. Select Save Map. .

Adding Layer Objects (with Vector Data) We will now re-add the popplace layer to our map. As you will remember, popplace is composed of vector data and therefore it contains some objects that the bathymetry layer does not. We will also make changes to this layer so that only Ottawa, the capital of Canada is displayed. 1. We need to add the popplace data to our mapfile. Use the same method you did before to add a new layer object. If you have forgotten, please refer back in the notes. 2. Click on the new layer at the bottom of the Object Browser. Once the properties for that layer opens, click on the Select a File button next to the Data Type parameter. The Open File window will appear and will immediately take you to the data folder for mymap.map. Here, you will see all the shapefiles used in this mapfile. Click on popplace.shp and then click OK.

5 of 12

15/09/2011 9:38

MapLab - tutorial

http://maps.unomaha.edu/Workshops/OpenSourceFiles/MapLab-tutorial.htm

3. Instead of naming this layer popplace we are going to change the name to capital. In the Name parameter type capital. 4. Now we must decide whether or not we want this data to be on or off. In this case we want this data to be off and the user will have to turn it on in the legend. Go to the Status parameter and using the drop down menu choose off. 5. Finally, we must specify what type of data this is. Since this is vector data we must indicate whether or not this data comes in the form of points, lines, or polygons. The popplace.shp is a point, so using the drop down menu choose point.

6. Since we want the capital layer to be one of the last layers drawn on the map, its location in the Object browser is fine. We, therefore, do not need to promote it. 7. Select Save Map from the File Menu dropdown. 8. Click on the Preview Map button and see what the changes have done. Click in the empty box next to capital in the legend and click on the Redraw map button . Did the capital appear? It did not appear because we have not classified the data. As mentioned previously, all vector data need class Objects. Adding Class Objects In this next section you will learn how to add class Objects to vector layers. 1. Click on the capital layer so that it is selected. Use the drop down menu in the toolbar and change Create New Object to Class Object. Now click on the Add new item button. You should see a class object appear underneath the capital layer. 2. We need to give the class a name that indicates what it being classified. Since we are going to classify this layer so that it only shows the capital of Canada type capital in the Name parameter. 3. The popplace.shp file contains information on many of the cities of Canada, however we only want Ottawa to be displayed on our map. To do this you need to add information to the Expression parameter so that only Ottawa is visible. To find out what type of information we need to add, you can open up the popplace.dbf file in a GIS program or a spreadsheet program like Excel. Once you are in one of these programs, navigate to c:\ms4w\apps\maplab-2.2\tutorial\data\ and open up popplace.dbf. The table that opens contains all the information for the popplace.shp. Look for the heading Name and either scroll down until you find Ottawa or do a find for Ottawa. Once you have found Ottawa look for the heading Capital. All cities are categorized in this heading as either a 0 (non-capital) a 1 (national capital) or a 2 (provincial capital). You will see that Ottawa is categorized as a 1. Close the spreadsheet program or the GIS program you were usin! g and return back to MapEdit. 4. Since the number 1 represents national capitals (hence Ottawa), go to the Expression parameter and type in 1. 5. Select Save Map from the File Menu dropdown to save the changes. 6. We also need to provide a symbol to mark Ottawa on the map, and in order to do this you must use a STYLE object, which is described in the next section. Adding a Style Object to a Class In order to specify colours and symbols for layers, a STYLE object must be added. 1. Click on the 'capital' CLASS object so that it is selected in the Object Browser. Use the drop down menu in the toolbar and change Create New Object to Style Object. Now click on the Add new item button. You should see a style object appear underneath the capital class. 2. Go to the Symbol parameter and click on the Select a symbol button you would like to represent Ottawa and then click OK. . The Symbol picker window will appear. Click on a symbol that

6 of 12

15/09/2011 9:38

MapLab - tutorial

http://maps.unomaha.edu/Workshops/OpenSourceFiles/MapLab-tutorial.htm

3. Now we need to select a color for our symbol. Go to the color parameter to pick a color. You can either enter in numbers or you can click on the Select a color button .

4. Once you have chosen a color, look at both the symbol and color parameter and you will notice their buttons display the color and symbol you picked. 5. The final step is to choose the size of your symbol. Scroll down the Object Properties frame until you see a parameter called Size (it is below the backgroundcolour parameter). In the empty field type 12. 6. Select Save Map from the File Menu dropdown. Selecting the ClassItem Field To classify an layer based on a certain attribute, you must specify the field to classify. 1. Return to the capital LAYER object by clicking it in the Object Browser. 2. Scroll down the list of parameters in the Object Properties Browser until you see a parameter called ClassItem. In this parameter we need to indicate what heading in the .dbf file we are using to classify our capitals. As you will recall the heading we used was called Capital. You can either type the name capital into the ClassItem parameter or click on the Select a file button. The Shape file attribute picker window will open. Scroll down until you see the heading capital, click on it and click OK.

3. Select Save Map from the File Menu dropdown. 4. Now click on the Preview map button and turn the cities layer on in the legend. You will see a symbol for Ottawa along the Quebec/Ontario broader. Adding Labels to a Class Object There is one missing piece to our map. We should add a label to show the name of the capital city of Canada. 1. Click on the Class Object underneath the capital layer. Use the drop down menu in the toolbar and change Create new object to Label Object. Click on the Add new item button. 2. Now click on the Label Object that appears underneath the Class Object. 3. The first thing we need to do is to pick a font that we want our label to be written in. Click on the Select font The Font picker window will appear. There are several fonts listed, pick one that you think is appropriate. button.

7 of 12

15/09/2011 9:38

MapLab - tutorial

http://maps.unomaha.edu/Workshops/OpenSourceFiles/MapLab-tutorial.htm

4. Now we need to determine whether this font is truetype or bitmap. Go to the Type parameter and using the drop down menu choose truetype. 5. Next, we need to decide where we want to position the label on the map. Go to the parameter called Position and using the drop down menu choose Auto. You can read up on what the other position do by clicking on the Help button and choosing MapServer reference v3.6.

6. Go to the parameter called Size, here we will choose the size of the font. You can do this in two ways. You can either use the drop down menu and choose from the sizes listed there (small, medium, large etc.) or you can type a number in the box titled integer. In the box titled integer enter in the number 8 7. 8. 9. 10. 11. 12. 13. 14. and choose a color for your font. We now need to give our font a color. Go to the color parameter and click on the Select a color button Select Save Map from the File Menu dropdown. Click on the Preview map button to see what your map looks like now. Do not forget to turn on the capital layer. You may have noticed that the label does not appear on your map, this is because we have one more step to complete. We need to tell our capital layer which field to use to get the name of our city. Click on the capital layer to open it up. Scroll down the Object Properties Frame until you see a parameter called LabelItem. Click on the Select a file button and click on Name. If you remember from the popplace.dbf file the name Ottawa was located underneath the Name heading. Now select Save Map from the File Menu dropdown. If your preview your map you should see the label.

MapBrowser
MapBrowser allows you to select spatial data from local and WMS servers.

MapBrowser's Work Area


MapBrowser is made up of four distinct areas: the toolbar, the legend, the data stores and the map preview area. The toolbar can be found across the top of the window and it is divided into MapLab buttons and MapBrowser buttons. The legend is in the upper left-hand corner and contains all the map layers. The data stores lists all the servers that are available to include data from and the map preview area displays your map.

8 of 12

15/09/2011 9:38

MapLab - tutorial

http://maps.unomaha.edu/Workshops/OpenSourceFiles/MapLab-tutorial.htm

Opening a Mapfile
1. If you are in MapEdit, click on the MapBrowser button . If you had the mymap.map file open, this file will automatically be displayed in MapBrowser. 2. If you are not in MapLab go there now and click on the MapBrowser heading. To open a file select the Open Map ... option from the File Menu dropdown . Navigate to the directory that contains mymap.map. Click on it and click Open.

Exploring MapBrowser
Let's take a moment to explore MapBrowser. 1. You can use the arrows surrounding the map to move the map to the north, south, east and west.

2. To return the map back to the initial view, click on the Zoom to Initial View button on the ROSA applet. 3. You can also use the Zoom in and Zoom out button to explore the map. Like the preview map in MapEdit, these buttons can be turned on or off. You will know that the Zoom in button is on when it is a light blue color and it will be off when it is a dark blue color . To zoom into an area, click on the Zoom in button so it is a light blue color. Drag a rectangular box around the area you want to zoom in to and watch as your map reloads and zooms into the area you chose. 4. Another interesting feature of MapBrowser is that you can set a custom view. This feature is useful if the map layer you are adding has a much smaller extent than the map. Instead of continually searching and zooming into the map layer you can set the custom view to easily view that map layer. Zoom into Newfoundland and click on the Set Custom view button applet to return to the full map. If you click on the Zoom to custom view button . This sets your custom view so you can return to in the ROSA in the ROSA applet, you will return to Newfoundland. Newfoundland after you have zoomed in and out of other areas on the map. Now click on the Zoom to Initial View button

Adding a Layer
Before we can add a layer we must first install a server, where we can obtain different map layers to add to our map. 1. We are going to add a layer from one of the WMS servers. The first thing we need to do is connect to a WMS server. Click on the Manage servers button . The Manage Servers window will open. 2. If you look in the Available Servers box you will see that there are several servers available to you. However, we will add the DM Solutions Group's WMS server from where you will obtain data. To do this type the following URL in the URL field: http://www2.dmsolutions.ca /cgi-bin/mswms_gmap?. Then click the Add Server button . You should see in the Available Servers box that the GMap WMS Demo Server has been added to the list of available servers. A (c) will be next to the server name indicating that you are connected to that server. Click on the Close button . 3. If you look in the data stores section of MapBrowser (bottom left-hand corner), you will see that GMap WMS Demo Server has been added. Click on the plus symbol next to this server. 4. GMap WMS Demo Server will appear underneath, click on the plus symbol next to its name. When you do, you should see the following layers listed below:

9 of 12

15/09/2011 9:38

MapLab - tutorial

http://maps.unomaha.edu/Workshops/OpenSourceFiles/MapLab-tutorial.htm

5. Most of these layers are already on your map. However, the one layer that is not is the parks layer. Click on the parks layer to add it and then click the Apply button .

6. You may notice that nothing happened and that an Alert symbol appeared in the upper left-hand corner of MapBrowser. Click on the Alert symbol to open up the Errors Occurred window. The error message tells us that the projection has not been set. For layers to be added in MapBrowser, a Projection Object must be added to the mapfile.

Adding a Projection Object


In this step we will go to MapEdit and add a Projection Object. 1. Click on the MapEdit button in the toolbar to return to MapEdit. Your mymap.map file should already be open. 2. Click on the Map object and ensure that it is selected. Then go to the drop down menu in the toolbar and change Create new object to Projection Object. Click on the Add new item button. 3. A Projection object should appear underneath Querymap and above Legend. Go to the Projection Object and click on it. 4. We are going to add the following code in the Project Attributes box: init=epsg:42304. This information says that we want our map of Canada to be in the Lambert Conformal Conic (LCC) projection for Canada.

5. Select the Save Map option from the File Menu dropdown. 6. We are now ready to return to MapBrowser. Click on the MapBrowser button in the toolbar.

Adding a Layer When the Projection has been Set


In this next section we will make a second attempt to add the parks. 1. Click on the plus symbols next to the GMap WMS Demo Server until all the layers appear. Now click on parks and then click the Apply

button . 2. You will notice that the parks layer appears above the capital layer in the legend. The radio button next to the layers tells us whether or not the layer is active. If a dot appears in the radio button it means it is active and can be manipulated . The box next to the layer tells us whether or not the layer is visible on the map. If a check mark appears in the box the layer is visible . 3. Looking at our parks layer, we can see that the layer is visible. For example, we can turn off the parks layer by clicking on the layer visibility box and removing the check mark. To make this change click on the Apply button. 4. We can also see that our layer is active. When a layer is active we can manipulate it. For example, because the parks layer is active we can use the Promote and Demote buttons to move the layer up and down. Or use the Delete active layer button to delete the layer. You may notice that the layers in MapBrowser are listed differently than in MapEdit. Here, the layers to be drawn first are at the bottom and the layers to be drawn last are at the top. Since we do not want parks to be the first layer drawn on the map (where it might hide other layers), we should demote it. Use the Demote button to move the parks layer from the top to above the land_fn (foreign land) layer and below the drain_fn (foreign drainage layer). 5. You may also notice that there is an information button next to the parks layer. This informs us that this layer is queriable. Turn on the . Go to the ROSA applet on the map and click on the Point query button visibility of the parks layer and click the Apply button Now click on one of the parks, you should see tiny cross hairs on the park. The Query results window will appear providing information about the park, like the park name and its area. 6. Select Save Map from the File Menu dropdown. .

GMapFactory
GMapFactory is a tool for rapid creation and deployment of mapping applications. In this tool you will be able to assemble all the parts to create your Web mapping application such as: the mapping tools to use (i.e., ROSA applet), the layout of the application, and the design of the application.

Creating a Project File


The first step is to create a folder to contain your project in. There are two ways to create an application depending on whether or not you already have an application open in MapLab. We will first describe what to do if you are already in MapLab with mymap.map open (steps 1 and 2) and then we will go on to describe what to do if you need to start MapLab and open your mymap.map mapfile (steps 3 and 4). 1. If you are still in MapBrowser click on the GMapFactory button this will open GMapFactory. The Quick Launch dialogue box will appear in GMapFactory saying that a project has not been selected yet. However it will already have a link to your mymap.map in the map file field.

10 of 12

15/09/2011 9:38

MapLab - tutorial

http://maps.unomaha.edu/Workshops/OpenSourceFiles/MapLab-tutorial.htm

2. Click on the link called select existing next to the project field. This will open up the GMapFactory window. In the top of the window will be a path describing the location of the project. Make a note of this location. Close the GMapFactory window. In the project field type mymap_project and click OK. This will be the name of your folder. You can now move on to the section titled Creating Your Application. 3. If you are not in MapLab or do not have mymap.map open, go to MapLab now and click on the GMapFactory heading. When GMapFactory opens, click on the Open existing file button in the toolbar. The GMapFactory window will appear. Where it says Application name, and navigate to where your mymap.map file is

type mymap_project. Where it says Map File click on the Browse button located. Click on it and then click OK.

4. GMapFactory will take a moment to create the application.

Creating Your Application


Creating the layout of your application is fairly simple. GMapFactory is divided into several sections each pertaining to a certain section of the map. We'll move through each of these section to find out what they do. 1. In the main map section you can choose the color of the border surrounding your map by clicking on the Select a color button. You can also choose the thickness of the border by clicking on the drop down menu next to border thickness. Finally, you can adjust the position of the map on the application by using the drop down menu next to position. Experiment with these three functions. Remember to click the Apply button to see what the application will look like.

2. In the map title section, you can decide whether or not you want a title by clicking the box next to map title to remove the check mark. For this tutorial leave the map title visible. In the text box type in Map of Canada. This will be the title that appears on our mapping application.. The drop down box next to size determine the size of font you want to use for your title. You can also pick the color of the font for your title and its position on the application. Experiment with all three of these functions.

3. The legend section affects what the legend will look like in your application. Like the map title section you can choose whether or not to have your legend visible by clicking on or off the check mark. The User Groups box allows you to enable groups in your legend display, for example you can create the group water and under water list the layers rives, lakes and oceans. However, to enable user groups you must set up groups in the mapfile. Since we have not done this, we will leave this option alone. You can also decide the location of the legend on your application.

11 of 12

15/09/2011 9:38

MapLab - tutorial

http://maps.unomaha.edu/Workshops/OpenSourceFiles/MapLab-tutorial.htm

4. In the scale bar section and key map section you can use the drop down menu to determine their locations on the map.

5. In the mapping tools section you can decide which tools you want in your application. For example, you may decide that you do not want the ROSA applet but you only want HTML tools displayed. You can also click on or off the various tools, like the zoom in button to determine whether or not you want them on your application. In the Zoom factor box you can decide how far the zoom in or zoom out button will zoom. If you are using HTML tools instead of the ROSA applet, you can use the drop down menu to decide where to position them on your map.

6. In the pan arrow section you can decide whether or not you want your pan arrows to surround the map or be assembled into a compass rose. If you chose the compass rose you can also decide where you would like to place it on your map by using the drop down menu.

7. Look at the heading called order, which is in each of the sections, and you will see up and down arrows. They are called the Promote button and the Demote button . These buttons change the order of the objects in the same column. For example if you have the legend and the keymap position in the left column you can use the promote and demote buttons to move the legend above the keymap. 8. Once you have your application assembled, click on the URL on the top right of the GMapFactory page to go to your new MapServer application. 9. There is one final correction to make on your application. If you look at your parks layer you will see it is oddly named in the legend. To provide this layer with a more proper name return back to MapEdit by clicking on the MapEdit button . 10. When MapEdit opens, find the layer GMap_WMS_Demo_Server-park layer in the Object Browser and click on it. In the Name parameter change the name to park. 11. Click Save. 12. Now return to GMapFactory. You will see that the parks layer is now properly named. Congratulations, your application is now ready to be published on the Web.

12 of 12

15/09/2011 9:38

Potrebbero piacerti anche