|Home | Products | Issue Tracker | FAQ | Download|
|Authors:||Dvaid Kana (david.kana at gmail.com)|
|Authors:||Thomas.Bonfort (thomas.bonfort at gmail.com)|
|Authors:||Yewondwossen Assefa (yassefa at dmsolutions.ca)|
|Authors:||Michael Smith (michael.smith at usace.army.mil)|
This purpose of this docuement is to describethe KML/KMZ output support in MapServer 6.0.
The main goal of the KML driver is to generate KML output used mainly by Google Earth application.
Kml support is provided by using a kml or kmz image type in the map file. Output can then be generated using MapServer cgi (example mode=map) or through a WMS request.
The default name of the output format is kml or kmz, and this name can be used to set the imagetype parameter in the map file.
The format can also be defined in the map file:
OUTPUTFORMAT NAME kml DRIVER "KML" MIMETYPE "application/vnd.google-earth.kml+xml" IMAGEMODE RGB EXTENSION "kml" FORMATOPTION 'ATTACHMENT=gmap75.kml' #name of kml file returned FORMATOPTION "maxfeaturestodraw=100" END OUTPUTFORMAT NAME kmz DRIVER "KMZ" MIMETYPE "application/vnd.google-earth.kmz" IMAGEMODE RGB EXTENSION "kmz" FORMATOPTION 'ATTACHMENT=gmap75.kmz' #name of kmz file returned END
The number of vector features drawn by default is set to 1000 per layer. To control the number of features, users can set:
In terms for Kml object, the MapServer KML output will produce a <Document> element to include all the layers that are part of the MapServer map file. Features supported for the Document are:
|Document element||Supportées||MapServer equivalence/Notes|
|name||Oui||Name in the map file|
|visibility||Non||Can be supported if needed. Default is 1|
|open||Non||Can be supported if needed. Default is 0|
|address||Non||Could be supported for example using ows_address if available|
|phoneNumber||Non||Could be supported using ows_contactvoicetelephone is available|
|StyleSelector||Oui||Style element will be supported. All different styles from the layers will be stored here and referenced from the folders using a styleUrl.In addition to the Styles related to features, there is a ListStyle element added at the document level. This allows to control the way folders are presented.See Layers section (styleUrl) setting for more details.|
Each layer of the MapServer map file will be inside a Kml <Folder> element. Supported Folder elements are:
|Folder element||Supportées||MapServer equivalence/Notes|
|name||Oui||Name of the layer. If not available the name will be Layer concatenated with the layer’s index (Layer1)|
|visibility||Oui||Always set to 1|
|open||Non||Default is 0|
|description||Non||Could be supported using ows_description|
|styleUrl||Oui||The user can use the kml_folder_display layer or map level metedata to choose a setting. Possible values are ‘check’ (default), ‘radioFolder’, ‘checkOffOnly’, ‘checkHideChildren’.|
Each element in the Layer will be inside a Kml <Placemark> element. As described in the Kml reference : “A Placemark is a Feature with associated Geometry. In Google Earth, a Placemark appears as a list item in the Places panel. A Placemark with a Point has an icon associated with it that marks a point on the Earth in the 3D viewer. (In the Google Earth 3D viewer, a Point Placemark is the only object you can click or roll over. Other Geometry objects do not have an icon in the 3D viewer. To give the user something to click in the 3D viewer, you would need to create a MultiGeometry object that contains both a Point and the other Geometry object.)”
For Polygon and Line layers, when a feature is associated with a label, a MultiGeometry element containing a point geometry and the geometry of the feature is created. The point feature will be located in the middle of the polygon or line
<Folder> <name>park</name> <visibility>1</visibility> <styleUrl>#LayerFolder_check</styleUrl> <Placemark> <name>Ellesmere Island National Park Reserve</name> <styleUrl>#style_line_ff787878_w4.0_polygon_ff00ffc8_label_ff0000ff</styleUrl> <MultiGeometry> <Polygon> <outerBoundaryIs> <LinearRing> <coordinates> … <Point> <coordinates> -70.86810858,82.12291871 </coordinates> </Point> </MultiGeometry> </Placemark> </Folder>
Supported Features in the Placemark element are:
|Placemark element||Supportées||MapServer equivalence/Notes|
|name||Oui||Label attached with the feature. If there is no label a default name is assigned using the layer name and the shape id (ex. park.1)|
|visibility||Non||Is is by default set to true|
|Snippet||Non||This is a short description the feature. If needed It could be supported.|
|description||Oui||This information is what appears in the description balloon when the user clicks on the feature. The <description> element supports plain text as well as a subset of HTML formatting elements. Used when KML/OWS_DESCRIPTION is defined|
|styleUrl||Oui||Refers to a Style defined in the Document|
|ExtendedData||Oui||Used when KML/OWS_INCLUDE_ITEMS is defined|
|Geometry||Oui||Depends on the layer type|
As described in Section 4, all different styles from the layers will be stored at the Document level and referenced from the folders using a styleUrl.
Point layers will be styled using the IconStyle styling element of kml. An image representing the symbol will be created and referenced from the IconStyle object. If a label is attached to the point, a LabelStyle element will also be used. The LabelStyle will have the color parameter set.
<Style id="style_label_ff0000ff_symbol_star_13.0_ff000000"> <IconStyle> <Icon> <href>>http://localhost/ms_tmp/4beab862_19bc_0.png</href> </Icon> </IconStyle> <LabelStyle> <color>ff0000ff</color> </LabelStyle> </Style>
Line layers will be styled using the LineStyle styling element of kml. Color and width parameters of the LineStyle will be used. If a label is attached to the layer, a LabelStyle element will also be used.
Polygon layers will be styled using the PolyStyle styling element of kml. Color parameter of the PolyStyle will be used. If an outline is defined in the map file, an addition LineStyle will be used. If a label is attached to the layer, a LabelStyle element will also be used.
As described in section on Layers, two ways of defining the description:
The map level projection should be set to epsg:4326. If not set, the driver will automatically set it. Layers are expected to have projection block if their projection is different from epsg:4326.