I have map with custom icon https://www.google.com/maps/d/u/0/edit?mid=1iwhgwHJgtmYOS6PokVdvTqTgpB51xCAg&usp=sharing
After import in KML icon turn into this https://www.gstatic.com/mapspro/images/stock/503-wht-blank_maps.png
There is result KML
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>test map</name>
<description/>
<Style id="icon-1594-7CB342-nodesc-normal">
<IconStyle>
<color>ff42b37c</color>
<scale>1</scale>
<Icon>
<href>https://www.gstatic.com/mapspro/images/stock/503-wht-blank_maps.png</href>
</Icon>
</IconStyle>
<LabelStyle>
<scale>0</scale>
</LabelStyle>
<BalloonStyle>
<text><![CDATA[<h3>$[name]</h3>]]></text>
</BalloonStyle>
</Style>
<Style id="icon-1594-7CB342-nodesc-highlight">
<IconStyle>
<color>ff42b37c</color>
<scale>1</scale>
<Icon>
<href>https://www.gstatic.com/mapspro/images/stock/503-wht-blank_maps.png</href>
</Icon>
</IconStyle>
<LabelStyle>
<scale>1</scale>
</LabelStyle>
<BalloonStyle>
<text><![CDATA[<h3>$[name]</h3>]]></text>
</BalloonStyle>
</Style>
<StyleMap id="icon-1594-7CB342-nodesc">
<Pair>
<key>normal</key>
<styleUrl>#icon-1594-7CB342-nodesc-normal</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#icon-1594-7CB342-nodesc-highlight</styleUrl>
</Pair>
</StyleMap>
<Folder>
<name>Campings</name>
<Placemark>
<name>Ein Yarkam camping</name>
<styleUrl>#icon-1594-7CB342-nodesc</styleUrl>
<Point>
<coordinates>
35.039418,30.945092,0
</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>
KML Export from My Maps does not support all the icon options provided in MyMaps. This is stated in the export dialog:
An alternative is to use the KMZ export (do not check the "Export as KML..." button), which will generate a KMZ file (zipped KML file) that includes the icon image bundled inside the zip.
Another option is to edit the KML in Google Earth or some other KML editor and change the icon. If you wanted, you could extract the icon from the KMZ, host it online somewhere, and then put the URL for that icon into your KML file.
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 am using KML with the Google Maps API. The KML is used to display Mile Markers on interstates (see screenshot):
A snippet of the KML:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Style id="randomLabelColor">
<LabelStyle>
<color>ff0000cc</color>
<colorMode>random</colorMode>
<scale>1.5</scale>
</LabelStyle>
</Style>
<Placemark>
<name>17</name>
<styleUrl>#randomLabelColor</styleUrl>
<description>I-684 MM NORTHBOUND: 17</description>
<Style>
<IconStyle>
<Icon>
<href>http://www.xxxx.com/images/mapicons/milemarker.png</href>
</Icon>
</IconStyle>
</Style>
<Point>
<coordinates>-73.67661,41.25393</coordinates>
</Point>
</Placemark>
</Document>
</kml>
I realize clicking the Mile Marker icon will display a callout with the name and description. But is it possible to have a label drawn on the map next to the icon? I would like to put the numeric mile marker on the map (e.g. 17)
Or instead of KML do I need to use javascript and create markers?
I've been looking for an answer to the same question. Going over the Google Maps API "KML and GeoRSS Layers" guide I noticed that the <LabelStyle> element is not supported.
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 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/>