Nokia Maps API Reference

Contents

Class nokia.maps.kml.component.KMLResultSet

Class Summary

This class represents a result set that can be initiated with a response from a KML file request.

Example of usage

			var kmlManager = new nokia.maps.kml.Manager(),
				resultSet,
				container;

			kmlManager.addObserver("state", function(kmlManager) {
				if (kmlManager.state == KMLManager.State.FINISHED) {
					resultSet = new nokia.maps.kml.component.KMLResultSet(kmlManager.kmlDocument);
					mapDisplay.objects.add(resultSet.create());
				}
			}, that);
			kmlManager.parseKML("sampleFile.kml");
		

new nokia.maps.kml.component.KMLResultSet (kmlDocument, [display])
Method Summary
addObserver (key, callback, [context]) : nokia.maps.util.OObject This method registers an observer for the property named by the caller.
create () : nokia.maps.map.Container This method asynchronously converts kmlDocument provided in the constructor to an instance of nokia.maps.map.Container.
get (key) : Variant This method retrieves the value of the property with the name provided by the caller.
getLineObject (geometry) : nokia.maps.map.Polyline This method converts an instance of LinearRing or LineString (a geometry) to a displayable map nokia.maps.map.Polyline.
getObjects (geometries) : nokia.maps.map.Container This method converts all the geometries supplied by the caller and puts them in a map container that can be displayed directly in map.
getPointObject (geometry) : nokia.maps.map.Marker | nokia.maps.map.StandardMarker This method converts the point geometry to a displayable map object.
getPolygonObject (geometry) : nokia.maps.map.Polygon This method converts a polygon geometry to a nokia.maps.map.Polygon that can be displayed on the map.
remove (key) : nokia.maps.util.OObject This method removes the property with the name provided by the caller.
removeObserver (key, callback, context) : nokia.maps.util.OObject This method removes the observer for the property named by the caller.
set (nameOrObject, [value, [force]]) : nokia.maps.util.OObject This method sets property values, using the property names and values supplied by the caller.
Field Summary
nokia.maps.map.Container container This property is a container of markers, representing the results.
String state This property holds the state of the container creation.
Direct Inheritance
Constructor Detail

Initialize a new instance of the class with the following parameters.

new nokia.maps.kml.component.KMLResultSet(kmlDocument, [display])
Parameters:
{nokia.maps.kml.Document} kmlDocument An instance of kml.Document that results from parsing a KML file
{nokia.maps.map.Display} [display] An instance of map.Display so that a map object listener can be added to ensure support for highlighted styles; if this argument is not provided by the caller, highlighted styles are not supported
Method Detail
This method asynchronously converts kmlDocument provided in the constructor to an instance of nokia.maps.map.Container.

When dealing with heavy KML files, please add the object returned by this method to the map display immediately. This method returns an empty nokia.maps.map.Container object and starts a nokia.maps.util.Coroutine which asynchronously fills it with objects held provided by the kmlDocument object. As a result, some of the kmlDocument objects may be rendered before others are added. When an entire kmlDocument is parsed and all the required containers and objects are created, the state of the KMLResultSet object is set to "finished". To receive notification of the state change, attach an observer as shown in the example below:

	var kmlManager = new nokia.maps.kml.Manager(),
		resultSet;

	kmlManager.addObserver("state", function (kmlManager) {
		// KML file was successfully loaded
		if (kmlManager.state == "finished") {
			// KML file was successfully parsed
			resultSet = new nokia.maps.kml.component.KMLResultSet(kmlManager.kmlDocument, map);
			resultSet.addObserver("state", function (resultSet) {
				if (resultSet.state == "finished") {
					// KML object tree was successfully converted into map objects
					// Get the bounding box of container
					boundingBox = resultSet.container.getBoundingBox();
					// Switch the viewport of the map do show all KML map objects within the container
					if (boundingBox) {
						map.zoomTo(boundingBox);
					}
				}
			});
			map.objects.add(resultSet.create());
		}
	});
	kmlManager.parseKML("sampleFile.kml");

The method uses a modified Breadth-first search algorithm to traverse the tree.

Returns:
{nokia.maps.map.Container} Returns map container which will hold map equivalents of KML objects
getLineObject (geometry) : nokia.maps.map.Polyline
This method converts an instance of LinearRing or LineString (a geometry) to a displayable map nokia.maps.map.Polyline.
Parameters:
{nokia.maps.kml.Point} geometry A KML line object or nokia.maps.kml.LineString object
Returns:
{nokia.maps.map.Polyline} A displayable map object that can be added directly to an instance of nokia.maps.map.Display
getObjects (geometries) : nokia.maps.map.Container
This method converts all the geometries supplied by the caller and puts them in a map container that can be displayed directly in map.
Parameters:
geometries An object that contains a hierarchical tree of geometries; the objects from the tree can be converted to map objects in KMLResultSet
Deprecated:
Using this function may trigger slow script warning in Internet Explorer 7 and 8. Please refer to nokia.maps.kml.component.KMLResultSet#create
Returns:
{nokia.maps.map.Container} A map container object that can be displayed on the map
This method converts the point geometry to a displayable map object. Depending on the style properties, the resulting object can be an instance of nokia.maps.map.Marker or nokia.maps.map.StandardMarker
Parameters:
{nokia.maps.kml.Point} geometry A KML point object
Returns:
{nokia.maps.map.Marker | nokia.maps.map.StandardMarker} An object that can be displayed on the map by adding it to an instance of nokia.maps.map.Display
getPolygonObject (geometry) : nokia.maps.map.Polygon
This method converts a polygon geometry to a nokia.maps.map.Polygon that can be displayed on the map.
Parameters:
{nokia.maps.kml.Polygon} geometry A KML polygon object
Returns:
{nokia.maps.map.Polygon} A displayable polygon that can be added directly to an instance of nokia.maps.map.Display
Field Detail
This property is a container of markers, representing the results.
String state
This property holds the state of the container creation. The possible values are: "initial", "started", "finished".
Documentation generated on Tue May 08 2012 10:23:49 GMT+0200 (CEST).