This work is licensed under a Creative Commons .
© 2007 Jaime M. As Nozawa. You are free to copy, distribute and transmit the work and make derivative works under the following conditions: a) You must give the original author. b) can not use this work for commercial purposes (including publication by s any means, for-profit entities). c) If you alter, transform this work or creates a derivative work, distribute the work only under a license identical to this one. For any reuse or distribution, you must make clear to others the license terms of this work. Any of these conditions can be waived if you get permission from the owner of the copyright. The rights under fair use and other constraints are not affected by the above. Full license Castilian. The information contained in this paper and those derived from it are provided as they are, the authors assume no liability if the user or reader of these misuses.Part 3 In this tutorial we'll do something interesting work without using a Mapfile (. Map). As you may have noticed the data is loaded according to the configuration. Map we've been working on lately, but I've seen always ask on the forums who always seems hard, having to be entering a text file to be adding layers or changing the color. In this part 3 of this tutorial, you will open new doors and the horizon as Web GIS Programmer, you will realize that we can, smooth but with some time to create our own Web interface management Mapserver (although there are projects like this but still in development).
I would say. Mapfile map or is like an "initial point" (. Ini). That means that we use to optimize the speed of MapServer layers to load default the first time they enter our application, and having done this, we'll review as it suits us.
This time we'll do something simple, try to do the tutorial # 1 but without using Mapfile ...
That means we will attempt to create a map as if there the next Mapfile: LAYER
NAME "Departments"
STATUS ON DATA "Lim_dep.shp" TYPE POLYGON
END
CLASS STYLE
COLOR 200 150 2
OutlineColor 0 0 0
END END
This Mapfile that I have is for reference only and WILL NOT BE USED .
Here I put my CODE EQUAL TO THE ABOVE:
1 \u0026lt;? Php
2 / / ejemplo01.php working without mapfile
3 / / Jaime M. As Nozawa 2007 Creative Co
4 5
/ / Load MapScript extension. Check if the extension is already loaded by default. 6
if (! extension_loaded ( "MapScript" )) dl ( 'php_
mapscript. " . PHP_SHLIB_SUFFIX )
7 8 / / instantiate a new object: map object. 9
$ JMap = ms_newMapObj ( " ) 10
11 $ JMap -> September ( " name " , " Evidence " )
12 $ JMap -> September ( " SHAPEPATH " , " C: / ms4w-php5 /
carpetaDondeestantusShapes
/ );
13
14 $ jMap -> setSize (600 , 400 );
15 $ jMap -> setExtent (- 87.9964, - 19.0216 , - 63,114 , 1.19528 );
16
17 18 $ JMap -> web -> September ( "ImagePath" , "C: / ms4w-php5/tmp/ms_tmp / " )
$ 19 JMap -> web -> September ( " imageurl " , " / ms_tmp / " )
20
21 / / Create a Layer within our MapObj and we set its properties
22 $jLayer = ms_newLayerObj ( $jMap );
23 $jLayer -> set ( "name" , "Departamentos" );
24 $jLayer -> set ( "type" , MS_LAYER_POLYGON );
25 $jLayer -> set ( "status" , MS_ON )
$ 26 jLayer -> September ( "data" , "Lim_dep.shp" )
27 28 / / Create a
LayerObj classObj within 29 $ JClass = ms_newClassObj ( $ jLayer )
30 31 / / We created a classObj styleObj within 32
$ jStyle = ms_newStyleObj ( $jClass );
33
34 $jStyle -> color -> setRGB ( 200 , 150 , 2 );
35 $jStyle -> outlinecolor -> setRGB ( 0 , 0 , 0 );
36
37 $ jImagen = $ JMap -> draw ();
38 39 / / create and capture the rendered image path. 40
$ url_imagen = $ jImagen -> saveWebImage ();
41 ?>
1) MapObj Here The creation of MapObj is performed without passing a parameter, so do not charge any. map:
$ JMap = ms_newMapObj ( " )
There is also an object that I set it up now" on the fly "is the object Web . This site does not have to object to instantiate, and is created automatically when you create an income so MapObj properties encountered:
18 $ JMap -> web -> September ( "ImagePath" , "C: / ms4w-php5/tmp/ms_tmp /" )
$ 19 JMap -> web -> September ( "imageurl" , "/ ms_tmp /" )
NEW Another property is SHAPEPATH. This property is needed to make things easier and not putting the whole path each time we add a layer and we refer to the location of shapefiel. (Note the data property of the Layer, and do not put long routes) 12 $ JMap -> September ( "SHAPEPATH" , "C: / ms4w-php5/carpetaDondeestantusShapes /" )
Look
clearly as I entering the properties, always with the "set" method for any object in the Map:
int set (string propertiedad, value)with set can change almost all properties of objects (unless you have a specialized property specific). If it returns a value of -1 means error.
2) Objects within the MAP
When I create a layer within the MapObj necessarily to instantiate it, I have to pass the object to which it is a party. In this case I think a layer LayerObj to be found within a MapObj:
ms_newLayerObj ( $ JMap )
As for the class or the style .. which are always contained within a larger object
$ 29 JClass = ms_newClassObj ( $ jLayer )
32 $ jStyle = ms_newStyleObj ( $ JClass )
3) constants:
addition to the above, have been used with new constants. In our case the rate constant Layers. In our example the type polygon.
Other possible values \u200b\u200bare:
MS_LAYER_POINT, MS_LAYER_LINE, MS_LAYER_POLYGON, MS_LAYER_RASTER, MS_LAYER_ANNOTATION
The latter type refers to an annotation layer.
Sometimes we want to label it alone or put
icons, logos for garnish or ease of comprehension, ETC.
---- Well that's it, I do not score because it would be the same as part 1. Can you try to change any of the property passing parameters using GET or SESSION. Or better yet, make a simple interface to configure the properties. Well you all in your imagination.
To always finish with a picture, here are a graph of the. Map (taken from the Book WebMapping ) I found sailing within the preview of the book.
enjoy it ... and do not forget to write and post their comments.
- NOTE UPDATE -
tutorial challenge: Recreate the map of the tutorial part 2, but without using a mapfile.
0 comments:
Post a Comment