gpt4 book ai didi

google-maps - Google Map OpenLayers Kml 图标名称

转载 作者:行者123 更新时间:2023-12-01 08:07:14 25 4
gpt4 key购买 nike

KML 文件:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<name>Name</name>
<description><![CDATA[]]></description>
<Style id="style140"><IconStyle>
<Icon>
<name>Name</name>
<href>icon/green.png</href>
</Icon>
</IconStyle>
</Style>
<Placemark>
<name>Name</name>
<description>Desc Name</description>
<styleUrl>#style140</styleUrl>
<Point>
<coordinates>12.7548360932222,59.2701399304516,0.000000</coordinates>
</Point>
</Placemark>
</Document>
</kml>

我得到了这个输出:

enter image description here

但我想要这个:

enter image description here

所以你可以看到点的名称。 kml 文件有什么问题?

谢谢!

最佳答案

我不知道这是否有帮助,但我发现您要使用的方法不起作用。我能够在 javascript 中以编程方式设置它。这使您可以在自己创建的红圈图标上方添加一个标签。

希望这对您有所帮助!

javascript(减去构建 map 对象等的其他代码):

function addLayer(){    
var myStyles = new OpenLayers.StyleMap({
"default": new OpenLayers.Style({
strokeColor: "#FFCC33",
strokeWidth:10,
strokeOpacity:1,
fillColor:"#003399",
fillOpacity: 1,
externalGraphic: "icons/redcircle.png",
labelYOffset: 15,
pointRadius: 5,
label:"${label}",
})
});

currentLayer = new OpenLayers.Layer.Vector("KML", {
styleMap: myStyles,
projection: map.displayProjection,
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "/kml/mymap.kml",
format: new OpenLayers.Format.KML({
extractStyles: true,
extractAttributes: true
})
})
});

KML 文件:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<description><![CDATA[]]></description>
<Placemark>
<label>Name</label>
<description>Desc Name</description>
<Point>
<coordinates>-122.98676101, 49.16702016,0.000000</coordinates>
</Point>
</Placemark>
</Document>
</kml>

关于google-maps - Google Map OpenLayers Kml 图标名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7665082/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com