Skip to content

Instantly share code, notes, and snippets.

@greggomann
Created August 5, 2011 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greggomann/1126944 to your computer and use it in GitHub Desktop.
Save greggomann/1126944 to your computer and use it in GitHub Desktop.
PIRE
<!-- This code parses through the below KML mapping data and utilizes the Google Maps API to calculate -->
<!-- land areas based on these coordinates. Javascript is found at the bottom. -->
<!-- Author: Greg Mann -->
<!-- Pacific Institute for Research and Evaluation, 2011 -->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>PIRE MUZ Area Calculator - 2011</title>
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAA8YSnLSDuxY__9frpprJN7RStF51Xnic-R6PcLJkIG3tO2lnhJBSxTbbsH-CvLzPF6fumG8XGxt0Caw"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?libraries=geometry&sensor=false"></script>
<script type="text/javascript">
var ge;
var kmlObject;
var txtBody;
txtBody = ''
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>R-1-N 1</name>'
+ ' <styleUrl>#style19</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.201317,33.850441,0 -118.201355,33.848774,0 -118.200066,33.848766,0 -118.20005,33.848492,0 -118.198692,33.848492,0 -118.198662,33.846638,0 -118.199715,33.846622,0 -118.199692,33.843349,0 -118.200203,33.843353,0 -118.200203,33.843426,0 -118.20182,33.84343,0 -118.201843,33.842926,0 -118.200256,33.842937,0 -118.200264,33.842644,0 -118.198471,33.84193,0 -118.19297,33.843937,0 -118.193565,33.843945,0 -118.193573,33.844852,0 -118.196426,33.844837,0 -118.196442,33.846069,0 -118.196976,33.846069,0 -118.196983,33.846703,0 -118.196907,33.846703,0 -118.196899,33.84726,0 -118.196259,33.847263,0 -118.196266,33.847977,0 -118.195778,33.847984,0 -118.195793,33.849178,0 -118.195549,33.849178,0 -118.195557,33.849522,0 -118.195702,33.849518,0 -118.195709,33.849823,0 -118.19754,33.849812,0 -118.197548,33.850441,0 -118.201317,33.850441,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>R-1-N 2</name>'
+ ' <styleUrl>#style10</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.19738,33.850449,0 -118.19738,33.850105,0 -118.195824,33.850105,0 -118.195824,33.85046,0 -118.19738,33.850449,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>R-3-S 1</name>'
+ ' <styleUrl>#style8</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.15184,33.778999,0 -118.15184,33.7757,0 -118.15023,33.775711,0 -118.15023,33.775837,0 -118.149155,33.775829,0 -118.149147,33.77718,0 -118.146988,33.777168,0 -118.146973,33.775829,0 -118.144852,33.775829,0 -118.144852,33.775867,0 -118.14386,33.775867,0 -118.148567,33.778992,0 -118.15184,33.778999,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>R-3-S 2</name>'
+ ' <styleUrl>#style1</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.145363,33.762367,0 -118.144287,33.762363,0 -118.144295,33.764267,0 -118.14534,33.764275,0 -118.145363,33.762367,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>R-3-4 1</name>'
+ ' <styleUrl>#style17</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.176781,33.786652,0 -118.176292,33.787971,0 -118.176331,33.786251,0 -118.175606,33.786251,0 -118.175621,33.788937,0 -118.176308,33.788937,0 -118.1763,33.789562,0 -118.176842,33.789562,0 -118.176842,33.78804,0 -118.176941,33.78804,0 -118.176941,33.787586,0 -118.180054,33.787582,0 -118.180046,33.787144,0 -118.179573,33.78714,0 -118.179581,33.786678,0 -118.178925,33.786682,0 -118.178925,33.786728,0 -118.178589,33.786732,0 -118.178589,33.78664,0 -118.178429,33.78664,0 -118.178421,33.786598,0 -118.178261,33.786598,0 -118.178261,33.786682,0 -118.177612,33.786686,0 -118.177605,33.786652,0 -118.176781,33.786652,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>R-3-4 2</name>'
+ ' <styleUrl>#style7</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.145882,33.783081,0 -118.145889,33.782188,0 -118.1437,33.7822,0 -118.1437,33.78207,0 -118.143219,33.782059,0 -118.143219,33.781952,0 -118.143066,33.781952,0 -118.143059,33.78207,0 -118.142647,33.78207,0 -118.142647,33.782234,0 -118.141533,33.782242,0 -118.141533,33.782082,0 -118.14109,33.782082,0 -118.141273,33.782589,0 -118.136833,33.782612,0 -118.136841,33.78299,0 -118.139328,33.78299,0 -118.139328,33.78315,0 -118.145882,33.783081,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>R-3-T 1</name>'
+ ' <styleUrl>#style25</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.151863,33.771988,0 -118.151863,33.771694,0 -118.150787,33.771706,0 -118.150787,33.771996,0 -118.151863,33.771988,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>R-3-T 2</name>'
+ ' <styleUrl>#style13</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.177811,33.854362,0 -118.177834,33.851185,0 -118.177208,33.850807,0 -118.176544,33.85091,0 -118.17614,33.851074,0 -118.176147,33.851322,0 -118.17675,33.851337,0 -118.17675,33.854355,0 -118.177811,33.854362,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>R-4-R 1</name>'
+ ' <styleUrl>#style3</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.184219,33.851955,0 -118.183823,33.85239,0 -118.183212,33.85265,0 -118.182312,33.852608,0 -118.180519,33.852043,0 -118.178589,33.851482,0 -118.177841,33.851166,0 -118.177223,33.850803,0 -118.177155,33.850094,0 -118.176132,33.850109,0 -118.175896,33.849628,0 -118.187164,33.845814,0 -118.187164,33.846432,0 -118.187088,33.847019,0 -118.18679,33.847786,0 -118.186295,33.848587,0 -118.18605,33.848988,0 -118.185776,33.848988,0 -118.18576,33.848598,0 -118.184875,33.848606,0 -118.184868,33.848434,0 -118.183861,33.848412,0 -118.183205,33.848598,0 -118.182854,33.848785,0 -118.182388,33.849056,0 -118.182114,33.849388,0 -118.181961,33.849667,0 -118.181976,33.849949,0 -118.182373,33.849976,0 -118.182701,33.850079,0 -118.183174,33.850368,0 -118.183426,33.850567,0 -118.183426,33.850967,0 -118.183357,33.851234,0 -118.183533,33.851505,0 -118.183861,33.851742,0 -118.184219,33.851955,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>R-4-R 2</name>'
+ ' <styleUrl>#style5</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.153496,33.874229,0 -118.153496,33.873924,0 -118.152451,33.873924,0 -118.152458,33.874218,0 -118.153496,33.874229,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>R-4-N 1</name>'
+ ' <styleUrl>#style22</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.193733,33.77776,0 -118.193726,33.778595,0 -118.193024,33.778595,0 -118.193024,33.778973,0 -118.193108,33.778973,0 -118.193108,33.779366,0 -118.193741,33.779369,0 -118.193741,33.781387,0 -118.191093,33.781391,0 -118.191078,33.780521,0 -118.191734,33.780521,0 -118.191734,33.780571,0 -118.192375,33.780571,0 -118.192375,33.778969,0 -118.191727,33.778973,0 -118.191719,33.77969,0 -118.191086,33.779697,0 -118.191093,33.780815,0 -118.190437,33.780815,0 -118.190437,33.777794,0 -118.193733,33.77776,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>R-4-N 2</name>'
+ ' <styleUrl>#style6</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.175171,33.84211,0 -118.175003,33.841682,0 -118.175011,33.841412,0 -118.175087,33.841064,0 -118.175331,33.840752,0 -118.175652,33.840538,0 -118.176056,33.840431,0 -118.176308,33.840389,0 -118.176308,33.840973,0 -118.175797,33.841225,0 -118.175804,33.84177,0 -118.175171,33.84211,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>RM 1</name>'
+ ' <styleUrl>#style26</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.215576,33.821575,0 -118.219513,33.821587,0 -118.220818,33.819019,0 -118.221153,33.818214,0 -118.221313,33.817459,0 -118.221344,33.815372,0 -118.215897,33.820911,0 -118.215897,33.821056,0 -118.215569,33.821392,0 -118.215576,33.821575,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>RM 2</name>'
+ ' <styleUrl>#style24</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.201805,33.84343,0 -118.20166,33.845371,0 -118.200218,33.845379,0 -118.200211,33.843418,0 -118.201805,33.84343,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>R-4-U 1</name>'
+ ' <styleUrl>#style2</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.192375,33.777756,0 -118.192383,33.777088,0 -118.19175,33.777088,0 -118.19175,33.776821,0 -118.191078,33.776814,0 -118.191093,33.777771,0 -118.192375,33.777756,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>CNR 1</name>'
+ ' <styleUrl>#style11</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.160049,33.772171,0 -118.160065,33.77124,0 -118.157837,33.771236,0 -118.157845,33.771713,0 -118.158928,33.771709,0 -118.158928,33.772163,0 -118.160049,33.772171,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>CNR 2</name>'
+ ' <styleUrl>#style23</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.169731,33.767223,0 -118.169601,33.767841,0 -118.167587,33.767582,0 -118.167648,33.76725,0 -118.167892,33.767284,0 -118.167999,33.766727,0 -118.168983,33.76685,0 -118.16893,33.767113,0 -118.169731,33.767223,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>CCR 1</name>'
+ ' <styleUrl>#style14</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.220444,33.804386,0 -118.22049,33.804173,0 -118.220337,33.804169,0 -118.22036,33.803944,0 -118.216545,33.803963,0 -118.216545,33.804386,0 -118.220444,33.804386,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>CCR 2</name>'
+ ' <styleUrl>#style18</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.183922,33.804359,0 -118.182289,33.804314,0 -118.182289,33.803894,0 -118.183876,33.803905,0 -118.183922,33.804359,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>CCN 1</name>'
+ ' <styleUrl>#style15</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.148621,33.789852,0 -118.148621,33.789009,0 -118.148064,33.789005,0 -118.147896,33.788967,0 -118.146637,33.788967,0 -118.146629,33.789852,0 -118.148621,33.789852,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>CCN 2</name>'
+ ' <styleUrl>#style9</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.194283,33.805698,0 -118.193718,33.80571,0 -118.193726,33.804413,0 -118.193024,33.804398,0 -118.193031,33.803871,0 -118.194283,33.803875,0 -118.194283,33.804813,0 -118.194786,33.80481,0 -118.194786,33.804996,0 -118.19429,33.804996,0 -118.194283,33.805698,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>CT 1</name>'
+ ' <styleUrl>#style20</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.182869,33.766544,0 -118.182411,33.766487,0 -118.182335,33.766903,0 -118.182137,33.76688,0 -118.182022,33.767414,0 -118.1819,33.767403,0 -118.181702,33.768497,0 -118.18222,33.768574,0 -118.182869,33.766544,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>PD 1</name>'
+ ' <styleUrl>#style4</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.149956,33.832245,0 -118.142662,33.832226,0 -118.140343,33.832245,0 -118.140343,33.830624,0 -118.138222,33.830532,0 -118.138222,33.825096,0 -118.134911,33.825085,0 -118.134941,33.823311,0 -118.141777,33.823296,0 -118.14225,33.823509,0 -118.155258,33.823563,0 -118.155235,33.824455,0 -118.155533,33.824741,0 -118.155983,33.824829,0 -118.155983,33.827663,0 -118.154152,33.827663,0 -118.154137,33.829037,0 -118.151985,33.829063,0 -118.151093,33.829624,0 -118.149956,33.832245,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>PD 2</name>'
+ ' <styleUrl>#style21</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.099167,33.818806,0 -118.099205,33.811199,0 -118.09816,33.811211,0 -118.098167,33.810505,0 -118.091698,33.810497,0 -118.092117,33.81789,0 -118.092262,33.818859,0 -118.092712,33.818848,0 -118.092598,33.818054,0 -118.095558,33.818035,0 -118.095558,33.81884,0 -118.099167,33.818806,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>CO 1</name>'
+ ' <styleUrl>#style16</styleUrl>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.180717,33.773811,0 -118.180206,33.775379,0 -118.17881,33.775349,0 -118.17881,33.774841,0 -118.177963,33.77483,0 -118.17794,33.775822,0 -118.180679,33.775829,0 -118.180679,33.77589,0 -118.184341,33.775902,0 -118.184334,33.77895,0 -118.184464,33.778969,0 -118.184486,33.782089,0 -118.185661,33.782082,0 -118.185684,33.78091,0 -118.185059,33.78091,0 -118.185043,33.778969,0 -118.185738,33.778969,0 -118.185753,33.778339,0 -118.185043,33.778332,0 -118.185028,33.777779,0 -118.185692,33.777779,0 -118.185707,33.77594,0 -118.185028,33.775928,0 -118.185059,33.775341,0 -118.180687,33.775341,0 -118.180717,33.773811,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>'
+ 'xxxx'
+ '<\?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">'
+ '<Placemark>'
+ ' <name>CO 2</name>'
+ ' <styleUrl>#style12</styleUrl>'
+ ' <gx:balloonVisibility>1</gx:balloonVisibility>'
+ ' <Polygon>'
+ ' <outerBoundaryIs>'
+ ' <LinearRing>'
+ ' <tessellate>1</tessellate>'
+ ' <coordinates>'
+ ' -118.180557,33.773979,0 -118.18013,33.773979,0 -118.180138,33.77354,0 -118.180252,33.773529,0 -118.180229,33.772236,0 -118.179047,33.772232,0 -118.179039,33.771732,0 -118.179184,33.771069,0 -118.180923,33.771328,0 -118.181068,33.770741,0 -118.181572,33.770821,0 -118.180557,33.773979,0 '
+ ' </coordinates>'
+ ' </LinearRing>'
+ ' </outerBoundaryIs>'
+ ' </Polygon>'
+ '</Placemark>'
+ '</kml>';
google.load("earth", "1");
function init() {
google.earth.createInstance('map3d', initCB, failureCB);
}
function initCB(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
var mapView = ge.createCamera('bakersfieldcam');
mapView.setLatitude(36.8);
mapView.setLongitude(-119.7);
mapView.setAltitude(7000);
ge.getView().setAbstractView(mapView);
var muzKmlArray = txtBody.split('xxxx');
var cbCoordString = '<table><div style="font-weight:bold; font-size:large"><tr><th>Zone Name</th><th>Area</th></tr></div>';
var kmlCounter = 0;
var kmlSize = 26;
while (kmlCounter < kmlSize) {
kmlObject = ge.parseKml(muzKmlArray[kmlCounter]);
ge.getFeatures().appendChild(kmlObject);
var cbArray = ge.getElementsByType('KmlPolygon').item(kmlCounter).getOuterBoundary().getCoordinates();
var cbSize = cbArray.getLength();
var cbCounter = 0;
var cbZoneName = ge.getElementsByType('KmlPlacemark').item(kmlCounter).getName();
cbCoordString = cbCoordString + '<tr><td>' + cbZoneName + '</td><td>';
var cbPolyArray = new Array();
while (cbCounter < cbSize) {
var cbTempLatLng = new google.maps.LatLng(cbArray.get(cbCounter).getLatitude(), cbArray.get(cbCounter).getLongitude());
cbPolyArray[cbCounter] = cbTempLatLng;
cbCounter++;
}
var cbZoneArea = 0.0;
cbZoneArea = google.maps.geometry.spherical.computeArea(cbPolyArray);
cbZoneArea = cbZoneArea / 1000000;
cbCoordString = cbCoordString + cbZoneArea + '</td></tr>';
kmlCounter++;
}
document.getElementById('notify').innerHTML = cbCoordString;
}
function failureCB(errorCode) {
}
google.setOnLoadCallback(init);
</script>
</head>
<body>
<div id="map3d" style="border: 1px solid silver; height: 400px; width: 600px;"></div>
<p id="textbox"></p>
<p id="notify"></p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment