/src/com/google/maps/extras/xmlparsers/kml/Placemark.as

http://gmaps-utility-library-flash.googlecode.com/ · ActionScript · 68 lines · 42 code · 6 blank · 20 comment · 6 complexity · c5e7f5de94f30db1ce0dd2fe4578f56f MD5 · raw file

  1. /*
  2. * Copyright 2008 Google Inc.
  3. * Licensed under the Apache License, Version 2.0:
  4. * http://www.apache.org/licenses/LICENSE-2.0
  5. */
  6. package com.google.maps.extras.xmlparsers.kml
  7. {
  8. import com.google.maps.extras.xmlparsers.Namespaces;
  9. import com.google.maps.extras.xmlparsers.ParsingTools;
  10. import com.google.maps.extras.xmlparsers.XmlElement;
  11. /**
  12. * Class that represents a <Placemark> element.
  13. *
  14. * @see http://code.google.com/apis/kml/documentation/kmlreference.html#placemark
  15. */
  16. public class Placemark extends Feature
  17. {
  18. private var _geometry:Geometry;
  19. private var _extended_data:ExtendedData;
  20. /**
  21. * Constructor for class.
  22. *
  23. * @param x
  24. */
  25. public function Placemark(x:XMLList)
  26. {
  27. super(x);
  28. // Features are: <Point>, <LineString>, <LinearRing>, <Polygon>, <MultiGeometry>, <Model>
  29. // We'll only support <Point>, <LineString>, <LinearRing>, <Polygon>, <MultiGeometry>
  30. if (ParsingTools.nullCheck(this.x.kml::Point)) {
  31. this._geometry = new KmlPoint(this.x.kml::Point);
  32. }
  33. if (ParsingTools.nullCheck(this.x.kml::LineString)) {
  34. this._geometry = new LineString(this.x.kml::LineString);
  35. }
  36. if (ParsingTools.nullCheck(this.x.kml::LinearRing)) {
  37. this._geometry = new LinearRing(this.x.kml::LinearRing);
  38. }
  39. if (ParsingTools.nullCheck(this.x.kml::Polygon)) {
  40. this._geometry = new KmlPolygon(this.x.kml::Polygon);
  41. }
  42. if (ParsingTools.nullCheck(this.x.kml::MultiGeometry)) {
  43. this._geometry = new MultiGeometry(this.x.kml::MultiGeometry);
  44. }
  45. if (ParsingTools.nullCheck(this.x.kml::ExtendedData)) {
  46. this._extended_data = new ExtendedData(this.x.kml::ExtendedData);
  47. }
  48. }
  49. /**
  50. * Represents the child geometry element (there can be only one).
  51. */
  52. public function get geometry():Geometry {
  53. return this._geometry;
  54. }
  55. public function get extendedData():ExtendedData {
  56. return this._extended_data;
  57. }
  58. public override function toString():String {
  59. return "Placemark: " + " geometry: " + this._geometry;
  60. }
  61. }
  62. }