I display KML polygons in Google maps.
When zooming in near the border of the polygon, the polygon border and fill becomes distorted and/or disappears.
(areas inside the polygon are not filled, and areas outside are filled).
Zooming back out resolves the issue.
Issue can be reproduced by copying and pasting the kml below into
http://display-kml.appspot.com/, then zooming in on the Western border of the box. (zoom in 4 clicks before I see the shading flip inside/outside).
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Folder>
<name>District</name>
<open>1</open>
<Placemark>
<MultiGeometry>
<Polygon>
<outerBoundaryIs><LinearRing><coordinates>
-92.02,38.53
-92.02,38.52
-92.45,38.52
-92.45,38.53
-92.02,38.53
</coordinates></LinearRing></outerBoundaryIs></Polygon>
</MultiGeometry>
</Placemark>
</Folder>
</Document>
</kml>
Images Here:
http://itic.occinc.com/good.png
(and bad.png) Stackoverflow would not let me post 3 links.
I believe this has been fixed. Thanks for the report!
Related
I have seen a few related questions but none answered my question completely.
This mentions Javascript: How to override KML colors in Google Map?
This mentions the KML color code helper but doesn't give a solution for applying it: Google Maps KML: 8-Digit Hex Code
The KML reference suggests using a <Style> but that didn't work: https://developers.google.com/kml/documentation/kmlreference#balloonstyle
Is there any way to set the color (or style, generally) for all markers of a given layer, so as to distinguish it from other layers?
This isn't perfect -- I'd rather there was an easy point-and-click way to do this in the UI -- but here goes.
Let's use a layer of markers for US National Parks as an example; taken from Wikipedia here: https://tools.wmflabs.org/kmlexport?article=List_of_national_parks_of_the_United_States
I've added these to a new map with the Import tool
I think the easiest way to do this is to apply all of the desired styling to a single marker within the UI, say the first one. For simplicity I just made it orange:
Now, export the layer to KML & open the KML file. Here's the condensed version of that file:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>National parks</name>
<Style id="icon-1899-0288D1-normal">
<IconStyle>
<color>ffd18802</color>
<!-- more attributes -->
</IconStyle>
<LabelStyle>
<scale>0</scale>
</LabelStyle>
</Style>
<Style id="icon-1899-0288D1-highlight">
<!-- similar markup -->
</Style>
<StyleMap id="icon-1899-0288D1">
<Pair>
<key>normal</key>
<styleUrl>#icon-1899-0288D1-normal</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#icon-1899-0288D1-highlight</styleUrl>
</Pair>
</StyleMap>
<!-- Two more <Style> tags for -normal and -highlight -->
<Style id="icon-1899-F57C00-normal"></Style>
<Style id="icon-1899-F57C00-highlight"></Style>
<!-- Another <StyleMap> -->
<StyleMap id="icon-1899-F57C00"></StyleMap>
<Placemark>
<name>Acadia</name>
<description>...</description>
<styleUrl>#icon-1899-F57C00</styleUrl>
<Point>...</Point>
</Placemark>
<Placemark>
<name>National Park of American Samoa</name>
<description>...</description>
<styleUrl>#icon-1899-0288D1</styleUrl>
<Point></Point>
</Placemark>
<!-- More <Placemark>s for the other parks -->
</Document>
</kml>
From here, we simply need to replace the reference style in the <styleUrl> of all of the labels with that used by Acadia. This is a simple find-and-replace-all. We can also remove the obsolete <Style>s and <StyleMap> but this is not strictly necessary. After that, save the updated KML and re-import it to Google Maps and we're done:
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 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 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/>