问题
We're using the Google Maps API and rendering a KML layer with markers. The marker icons though are not rendering at scales greater then 1 even though the scales are defined. If I use geoxml3 the scaling works but a number of other problems crop-up which I'd rather not have to deal with. It's a pretty simple KML, here's a relevant Style block:
<Style id="Style1">
<IconStyle>
<scale>1.875</scale>
<Icon>
<href>https://www.smud.org/assets/images/outage/x-lg.png</href>
</Icon>
</IconStyle>
</Style>
Here's a marker (I can provide the schema xml if that's helpful):
<Folder>
<name>map_outages_5000+</name>
<Placemark>
<name>5000+</name>
<styleUrl>#Style1</styleUrl>
<ExtendedData>
<SchemaData schemaUrl="#Schema1">
<SimpleData name="EVENTNUMBER">D16020400019</SimpleData>
<SimpleData name="AFFECTEDAREA">Executive Airport</SimpleData>
<SimpleData name="OUTAGEBEGINTIME">02/04/2016 13:49:45</SimpleData>
<SimpleData name="ESTIMATEDRESTORATIONTIME">02/04/2016 14:50:00</SimpleData>
<SimpleData name="CUSTOMERSIMPACTED">14906</SimpleData>
<SimpleData name="OUTAGEDESCRIPTION"></SimpleData>
<SimpleData name="CALLCOUNT">0</SimpleData>
<SimpleData name="X_COORD">6699236.5229</SimpleData>
<SimpleData name="Y_COORD">1946587.0231</SimpleData>
<SimpleData name="CoordGeocodeStatus"></SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-121.519315773898,38.5063426658563,30.4334760147827</coordinates>
</Point>
<description><![CDATA[<div style="clear:both;color:#231f20;"><p style="font-size:18px;font-weight:bold;text-align:center">Executive Airport</p><div style="clear:both; font-size: 12px;"><p>Occured at </br><b>1:49 PM February 4</b></p></div><div style="clear:both; font-size: 12px;"><p>Est Restoration </br><b>2:50 PM February 4</b></p></div><div style="clear:both; font-size: 12px;"><p>Customers Out </br><b>14906</b></p></div><div style="clear:both; font-size: 12px;"><p>Customer Calls </br><b>0</b></p></div></div><div style="clear:both;"><p style="color:#959595; padding-top: 20px; font-size:12px;text-align:center">Ref # D16020400019</p></div>]]></description>
</Placemark>
</Folder>
The relevant block of JS is as follows:
var activeOutages = new google.maps.KmlLayer({
url: 'https://sampleurl.com/file.kml',
zIndex: 2,
preserveViewport: true,
map: map
});
Again it renders fine in general, it just doesn't scale the markers properly. I have 5 different maker sizes and it wont render anything larger than 32px (or a scale of 1). I saw another question where someone had accidentally set their scale attribute too large and it was rendering it over-sized. So it seems that it was possible, I'm hoping I'm just missing a setting in the layer object. I don't see anything in the documentation about scales larger then 1 not being supported and one example uses a scale of 1.1 which implies larger should be possible.
Any help would be great. Thanks.
回答1:
Related issue from the issue tracker: Issue 2444: Using KML layers with icons smallere then 32x32px (from Feb 13, 2013).
Indicates:
KML scale tag is supported but is currently implemented as the scale of '32x32' final icon, i.e. your supplied icon image will be resized to 32x32 first (aspect ratio conserved), regardless of its original size. Then the scale tag, whose valid value can only be between (0,1], is applied. For example, 0.5 of a 64x64 png image will result in a 16x16 map icon.
来源:https://stackoverflow.com/questions/35487647/marker-scales-greater-than-1-ignored-when-using-a-kml-layer-with-the-google-maps