I have a kml file that looks like the next:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>KML file with polygon for bird species range</name>
<description>Source various books and websites</description>
<Style id="rangecolour">
<LineStyle><color>660000FF</color><width>1</width></LineStyle>
<PolyStyle><color>660000FF</color></PolyStyle>
</Style>
<Style id="linecolour">
<LineStyle><color>660000FF</color><width>3</width></LineStyle>
</Style>
<Placemark><name>distribution/range</name>
<description></description>
<styleUrl>#rangecolour</styleUrl>
<Polygon>
<tessellate>1</tessellate>
<altitudeMode>clampToGround</altitudeMode>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-180.0,180.0,0.0
-180.0,-180.0,0.0
180.0,-180.0,0.0
180.0,180.0,0.0
-180.0,180.0,0.0
</coordinates>
</LinearRing>
</outerBoundaryIs>
<innerBoundaryIs>
<LinearRing>
<coordinates>
153.056374,-27.500658,0.0
153.056374,-27.524105,0.0
153.093109,-27.524105,0.0
153.093109,-27.500658,0.0
153.056374,-27.500658,0.0
</coordinates>
</LinearRing>
</innerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</kml>
My intention is to do a "hole" inside the entire world to get shadded all the world outside a boundaries (this is just an example), but, for some reason that I don't know, in Google Earth works fine, but in google maps (API v3, at least... is the one I'm using with "google.maps.KmlLayer(url.kml)"...) not.
Does anyone know why?
The outer boundary is:
<coordinates>
-180.0,180.0,0.0
-180.0,-180.0,0.0
180.0,-180.0,0.0
180.0,180.0,0.0
-180.0,180.0,0.0
</coordinates>
which is a very narrow square (between -180 and +180)
The KML displayed below uses this for the polygon (the whole world with a small hole):
<Placemark><name>distribution/range</name>
<description></description>
<styleUrl>#rangecolour</styleUrl>
<Polygon>
<tessellate>1</tessellate>
<altitudeMode>clampToGround</altitudeMode>
<outerBoundaryIs>
<LinearRing>
<coordinates>
180,85
90,85
0,85
-90,85
-180,85
-180,0
-180,-85
-90,-85
0,-85
90,-85
180,-85
180,0
180,85
</coordinates>
</LinearRing>
</outerBoundaryIs>
<innerBoundaryIs>
<LinearRing>
<coordinates>
153.056374,-27.500658,0.0
153.093109,-27.500658,0.0
153.093109,-27.524105,0.0
153.056374,-27.524105,0.0
153.056374,-27.500658,0.0
</coordinates>
</LinearRing>
</innerBoundaryIs>
</Polygon>
</Placemark>
This works for me with geoxml3, doesn't work with KmlLayer.
Another example
I don't know why, the Google Maps KML parser and KmlLayer have pretty much always been broken this way.
Related question: shading area outside of kml boundary
Related
I am trying to figure out how to highlight a line segment when I hover over it in Google Earth.
This is what it currently looks like when I hover over it. Notice that the whole line stays blue:
Imgur
This is what I want it to look like when I hover over it. The segment should change color:
Imgur
Is there a way to do this with code? Do I need to convert it to a different file type?
To change a line in Google Earth when you mouse over or hover on it then you need the KML to define a StyleMap that with a style for "normal" mode and another for "highlight" mode.
In the example below, the line shows a thin blue line by default showing the normal style, but changes to a thicker purple line when you hover the mouse over the line which then switches to the highlight style.
Example:
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Style id="sn">
<LineStyle>
<color>7fff0000</color>
<width>2</width>
</LineStyle>
<PolyStyle>
<color>7fff0000</color>
</PolyStyle>
</Style>
<Style id="sh">
<LineStyle>
<color>7fff00ff</color>
<width>8</width>
</LineStyle>
<PolyStyle>
<color>7f00ff00</color>
</PolyStyle>
</Style>
<StyleMap id="msn">
<Pair>
<key>normal</key>
<styleUrl>#sn</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#sh</styleUrl>
</Pair>
</StyleMap>
<Placemark>
<name>Style Map example</name>
<styleUrl>#msn</styleUrl>
<LineString>
<tessellate>1</tessellate>
<altitudeMode>absolute</altitudeMode>
<coordinates>
-112.265654928602,36.09447672602546,2357
-112.2660384528238,36.09342608838671,2357
-112.2668139013453,36.09251058776881,2357
-112.2677826834445,36.09189827357996,2357
-112.2688557510952,36.0913137941187,2357
-112.2694810717219,36.0903677207521,2357
-112.2695268555611,36.08932171487285,2357
-112.2690144567276,36.08850916060472,2357
-112.2681528815339,36.08753813597956,2357
-112.2670588176031,36.08682685262568,2357
-112.2657374587321,36.08646312301303,2357
</coordinates>
</LineString>
</Placemark>
</Document>
</kml>
I have a kml with a polygon of the work area of a company.
I would like to blur the whole outside to clearly highlight this area is not in scope.
Note: on the screen shot, the red edge is a style of the polygon. I'll remove it.
Any idea on how to do this ?
example of blurred outer polygon
Code in the kml (removed unrelevant parts)
<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document id="root_doc">
<Folder>
<name>Angervilliers_AL8</name>
<Placemark>
<name>Angervilliers</name>
<Style>
<LineStyle>
<color>ff0000ff</color>
</LineStyle>
<PolyStyle>
<fill>0</fill>
</PolyStyle>
</Style>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>1.8823674,48.5142152 1.8837864,48.5138449 ...</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Folder>
</Document>
</kml>
To get this effect, you'll want to create a larger polygon outline to cover the "blurred" area, and then an inner line for the "hole" in the polygon (the area you want to keep clear in the middle). These go in <outerBoundaryIs> and <innerBoundaryIs> tags inside your <Polygon> tag.
Below is a working example... try copy/pasting it into Earth Pro. Note also the <LookAt> section that forces the view to be zoomed in on the inner polygon, so the user won't notice the outer boundary of the polygon unless they zoom way out.
<?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">
<Document id="root_doc">
<name>Inverted Polygon Demo</name>
<Placemark>
<name>Angervilliers</name>
<LookAt>
<longitude>2.06384</longitude>
<latitude>48.59146</latitude>
<heading>0</heading>
<tilt>0</tilt>
<range>3000</range>
</LookAt>
<Style>
<LineStyle>
<color>ff0000ff</color>
</LineStyle>
<PolyStyle>
<fill>1</fill>
<color>88ffffff</color>
</PolyStyle>
</Style>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
0.3184451839056446,47.78618899775447,0 3.661259487435122,47.80641551814697,0 3.695580055346501,49.36244976492695,0 0.2356130804739087,49.36861085533987,0 0.3184451839056446,47.78618899775447,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
<innerBoundaryIs>
<LinearRing>
<coordinates>
2.058365295534554,48.59459332179971,0 2.055806623017014,48.59347610558855,0 2.051167395626068,48.59309196143701,0 2.053826722439367,48.59152032273916,0 2.059404688365358,48.5906235533257,0 2.058795280866135,48.58977412250532,0 2.053976866512941,48.58818157946221,0 2.055353500059218,48.58521810150005,0 2.060326614008405,48.58453057119874,0 2.06261321438489,48.59037827408845,0 2.065888887077823,48.59124861689973,0 2.071575394540492,48.59109027523166,0 2.075460981003194,48.59050363005721,0 2.077744729364595,48.59052448781961,0 2.078079473747407,48.59149049454836,0 2.072318523336512,48.59352956508539,0 2.072078869584328,48.59455791455283,0 2.068689814773501,48.59359361048438,0 2.068109548294674,48.59488295734163,0 2.064472047819985,48.5969248658065,0 2.060703393863961,48.59688230010441,0 2.058365295534554,48.59459332179971,0
</coordinates>
</LinearRing>
</innerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</kml>
I have a kml file base on the on the tutorials presented by Google Earth developer website and by this link. My goal is to draw a line which is contained within a region (fades as I zoom out from it) and that is able to display the label name along the line trajectory.
Instead of the question mark I would like to have the name of such line.
So far I have implemented this lines of code:
<?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">
<Document>
<name>KmlFile</name>
<Placemark>
<name>SFO to LAX</name>
<Style id="line_label">
<LabelStyle>
<scale>10</scale>
</LabelStyle>
<LineStyle>
<color>ff00ffff</color>
<width>5</width>
<gx:labelVisibility>1</gx:labelVisibility>
</LineStyle>
</Style>
<LineString>
<tessellate>1</tessellate>
<coordinates>
-118.40897,33.943492,0 -122.383103,37.617112,0
</coordinates>
</LineString>
<Region>
<LatLonAltBox>
<north>37.617112</north>
<south>33.943492</south>
<east>-118.40897</east>
<west>-122.383103</west>
<minAltitude>0</minAltitude>
<maxAltitude>200000</maxAltitude>
<altitudeMode>clampToGround</altitudeMode>
</LatLonAltBox>
<Lod>
<minLodPixels>1024</minLodPixels>
<minFadeExtent>1024</minFadeExtent>
</Lod>
</Region>
</Placemark>
<Placemark>
<name>BOH to MAH</name>
<Style id="line_label">
<LabelStyle>
<scale>1.3</scale>
</LabelStyle>
<LineStyle>
<color>ff00ffff</color>
<width>5</width>
<gx:labelVisibility>1</gx:labelVisibility>
</LineStyle>
</Style>
<LineString>
<tessellate>1</tessellate>
<coordinates>
-117.40897,34.943492,0 -121.383103,38.617112,0
</coordinates>
</LineString>
</Placemark>
</Document>
</kml>
Can you please suggest me a way to achieve my goal?
Apparently adding the Region to the Placemark doesn't correctly enable the labelVisibility mode in the line style when the feature becomes active. This is a bug in Google Earth. LabelVisibility works only if you don't use a Region.
You can get around this, by adding a Point within a MultiGeometry to the placemark to active with Region. Having a point enables the label to be displayed and the label is displayed at the location of the point.
<Placemark>
<name>SFO to LAX</name>
<Style>
<IconStyle>
<Icon/>
</IconStyle>
<LabelStyle>
<scale>1.3</scale>
</LabelStyle>
<LineStyle>
<color>ff00ffff</color>
<width>5</width>
<gx:labelVisibility>1</gx:labelVisibility>
</LineStyle>
</Style>
<Region>
...
</Region>
<MultiGeometry>
<Point>
<coordinates>-119.884604,35.349412</coordinates>
</Point>
<LineString>
<tessellate>1</tessellate>
<coordinates>
-118.40897,33.943492 -122.383103,37.617112
</coordinates>
</LineString>
</MultiGeometry>
</Placemark>
The workaround is to place Region in a higher level from Placemark to Folder or Document.
Works great.
I have a problem with the tool tip in google map.
As you can to see, I have one polygon in my map. But when I click on this polygon as you see in the kml display, the display of the tooltip is cut (Click on the zone map).
To realized this map, I used a KML file, the KML is generated with JAK API.
I think it should be possible to modify the css of the tool tip with the api but I don't know how. I already searched a couple of hours.
I m not an expert with this API and Google Map. So If you have any advice to resovle this problem don't hesitate. I'm going to continue to search.
Thank you so much in advance for your help.
You'll find below a set of image that explains the problem :
URL To test a KML File :
http://display-kml.appspot.com/
Content of the KML File :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
<Document>
<name>IBR</name>
<Style>
<PolyStyle id="toolTip">
<color>0xb9cbf1</color>
<colorMode>normal</colorMode>
<fill>1</fill>
<outline>1</outline>
</PolyStyle>
</Style>
<Style>
<LineStyle id="lineStyle">
<color>0x666ef8</color>
<width>1.0</width>
</LineStyle>
</Style>
<Placemark>
<name>Edmonton Yp</name>
<styleUrl>#toolTip</styleUrl>
<Polygon>
<extrude>1</extrude>
<altitudeMode>relativeToGround</altitudeMode>
<outerBoundaryIs>
<LinearRing>
<coordinates>-113.99345397949219,53.65755844116211 -113.98419189453125,53.59413146972656 -113.93543243408203,53.42497253417969 -113.68433380126953,53.25069046020508 -113.68347930908203,53.250675201416016 -113.67694091796875,53.250667572021484 -113.39179992675781,53.25058364868164 -113.3207778930664,53.25060272216797 -112.96499633789062,53.39612579345703 -112.87796020507812,53.45442199707031 -112.80402374267578,53.51348114013672 -112.80384826660156,53.54147720336914 -112.80400848388672,53.57035827636719 -112.95169067382812,53.65762710571289 -113.29582214355469,53.71658706665039 -113.56759643554688,53.720455169677734 -113.93214416503906,53.71586608886719 -113.93550872802734,53.715370178222656 -113.99345397949219,53.65755844116211</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</kml>
I have a embedded map on my site in which I display various location based on the user's search results. In some cases we do not have location data and instead display a screen overlay indicating this. I additionally set a couple of placemarks to force the map to zoom and center on a specific region (the default if there is no location data being the full zoom out, which is kind of ugly).
My problem is I want to hide these placemarks, as otherwise they appear to indicate there are locations available and none of the following has worked:
the visibility flag on elements seems to only be supported in google earth
a custom transparent png specified as the Placemark Icon href does not load, and I get the default blue pin.
I tried creating a region on the folder which encompasses the placemarks and setting a LOD which should disable it, but this appears to not do anything at all (KML below).
I believe I am missing a simple way to accomplish this, but a nudge would be helpful. Here is the KML using regions:
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<ScreenOverlay>
<Icon>
<href>URL/mapDisclaimer.png</href>
</Icon>
<overlayXY x="0.5" xunits="fraction" y="0.5" yunits="fraction" />
<screenXY x="0.5" xunits="fraction" y="0.5" yunits="fraction" />
<size x="0" xunits="pixels" y="0" yunits="pixels" />
</ScreenOverlay>
<Folder>
<name>PlaceHolderFolder</name>
<Style id="placeholderStyle">
<IconStyle>
<Icon>
<href>URL/transparentBlock.png</href>
</Icon>
</IconStyle>
</Style>
<Region>
<LatLonAltBox>
<north>79</north>
<south>59</south>
<east>-102</east>
<west>-137</west>
</LatLonAltBox>
<Lod>
<maxLodPixels>20</maxLodPixels>
</Lod>
</Region>
<Placemark>
<styleUrl>#placeholderStyle</styleUrl>
<Point>
<coordinates>-136.582031,69.16256</coordinates>
</Point>
</Placemark>
<Placemark>
<styleUrl>#placeholderStyle</styleUrl>
<Point>
<coordinates>-110.566406,78.560486</coordinates>
</Point>
</Placemark>
<Placemark>
<styleUrl>#placeholderStyle</styleUrl>
<Point>
<coordinates>-102.128906,59.977005</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>
The transparent PNG should work, but you must move the <Style/>-element out of <Folder/> and make it a child of <Document/>