Google maps 谷歌地图OpenLayers Kml图标名称
KML文件:Google maps 谷歌地图OpenLayers Kml图标名称,google-maps,kml,openlayers,Google Maps,Kml,Openlayers,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">&l
<?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>
<?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>
名称
名称
icon/green.png
名称
描述名称
#样式140
12.7548360932222,59.2701399304516,0.000000
我得到这个输出:
但我想要这个:
因此,您可以看到点的名称。kml文件中有什么错误
谢谢 我在Google Earth中看到了默认情况下完全不透明的白色placemark名称标记。尝试在样式中指定标签样式元素以获得该颜色和不透明度
<?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>
<LabelStyle>
<color>ffff55ff</color>
</LabelStyle>
</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>
名称
名称
icon/green.png
ffff55ff
名称
描述名称
#样式140
12.7548360932222,59.2701399304516,0.000000
我不知道这是否有帮助,但我发现您想要使用的方法不起作用。我可以用javascript编程设置它。这允许您在自己创建的红圈图标上方有一个标签
希望这有帮助
javascript(减去构建映射对象等的其他代码):
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>
<?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>
名称
描述名称
-122.98676101, 49.16702016,0.000000
这就是我解决问题的方法……希望这能有所帮助
var layerData = new OpenLayers.Layer.Vector("test1", {
renderers: ["SVG", "Canvas", "VML"],
strategies: [new OpenLayers.Strategy.Save({
auto:true
}),new OpenLayers.Strategy.Cluster({
distance: clusteringDistance,
threshold: clusteringThreshold,
shouldCluster: function(cluster, feature) {
updateFeatureStyle(feature);
if (feature.geometry.CLASS_NAME == "OpenLayers.Geometry.Point" && boundArea >= maxBoundAreaForClustering) {
return OpenLayers.Strategy.Cluster.prototype.shouldCluster.apply(this, arguments);
} else {
return false;
}
}
})],
styleMap: clusterStyle
});
blankLayer = true;
layerData.setVisibility(false);
function updateFeatureStyle(feature) {
feature.style.label = "\n\n " + feature.attributes.name;
feature.style.labelAlign = 'ct';
feature.style.fontColor = 'red';
feature.style.fontFamily = 'Arial';
feature.style.fontSize = '10px';
feature.style.fontOpacity = 1;
feature.style.graphicTitle = feature.attributes.name;
}
那么它一定是openlayers特定的东西。我认为这值得一试,但唉,我不熟悉openlayers。很抱歉