Class nokia.maps.kml.component.KMLResultSet
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");
kmlDocument provided in the constructor to an instance of nokia.maps.map.Container.
LinearRing or LineString (a geometry) to a displayable map nokia.maps.map.Polyline.
nokia.maps.map.Polygon that can be displayed on the map.
Initialize a new instance of the class with the following 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
|
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.
| {nokia.maps.map.Container} | Returns map container which will hold map equivalents of KML objects |
LinearRing or
LineString (a geometry) to a displayable map
nokia.maps.map.Polyline.
| {nokia.maps.kml.Point} | geometry | A KML line object or nokia.maps.kml.LineString object |
| {nokia.maps.map.Polyline} |
A displayable map object that can be
added directly to an instance of nokia.maps.map.Display
|
| geometries |
An object that contains a hierarchical tree of geometries;
the objects from the tree can be converted to map objects in
KMLResultSet
|
| Using this function may trigger slow script warning in Internet Explorer 7 and 8. Please refer to nokia.maps.kml.component.KMLResultSet#create |
| {nokia.maps.map.Container} | A map container object that can be displayed on the map |
nokia.maps.map.Marker or
nokia.maps.map.StandardMarker
| {nokia.maps.kml.Point} | geometry | A KML point object |
| {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
|
nokia.maps.map.Polygon that can be displayed on the map.
| {nokia.maps.kml.Polygon} | geometry | A KML polygon object |
| {nokia.maps.map.Polygon} |
A displayable polygon that can be added
directly to an instance of nokia.maps.map.Display
|
