Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Api Google Earth:使用JAK从KML检索图标URL_Api_Url_Kml_Google Earth_Jak - Fatal编程技术网

Api Google Earth:使用JAK从KML检索图标URL

Api Google Earth:使用JAK从KML检索图标URL,api,url,kml,google-earth,jak,Api,Url,Kml,Google Earth,Jak,我目前正在使用JAK(用于KML的JavaAPI)与GoogleEarth和定制的KML文件进行交互。我可以使用placemark p.getName()或point.getCoordinates()等工具获取/设置地名的名称、描述和坐标;进入一个列表,等等,但我有麻烦的是得到的图像用于图标的url。例如,如果我的kml文件中有这个位置标记(包含在文档中,然后是整个kml标记中): 罗坦岛 巡航站 http://maps.google.com/mapfiles/kml/shapes/airpo

我目前正在使用JAK(用于KML的JavaAPI)与GoogleEarth和定制的KML文件进行交互。我可以使用placemark p.getName()或point.getCoordinates()等工具获取/设置地名的名称、描述和坐标;进入一个列表,等等,但我有麻烦的是得到的图像用于图标的url。例如,如果我的kml文件中有这个位置标记(包含在文档中,然后是整个kml标记中):


罗坦岛
巡航站
http://maps.google.com/mapfiles/kml/shapes/airports.png
-86.53,16.337461,0

我怎样才能抓取png url来表示,放在一个单独的字符串对象中?我在样式中看到了.getIconStyle,在IconStyle中看到了.getIcon,在Icon中看到了.getHttpQuery,但是除了.getStyleSelector和.getStyleUrl之外,没有任何链接可以从Placemark/Feature查看样式。你能用其中一个或一个样式图来做吗?我不确定我是否完全掌握了它们的作用。另外,反过来说,如何设置此URL?谢谢你的帮助

Feature.getStyleSelector()
返回一个
列表
Style
StyleSelector
的子类,因此您的样式应该在此列表中(以及为功能定义的任何其他样式和样式映射)

设置样式(和图标URL):

获取样式(和图标URL):


非常感谢。为了满足我的需要,我做了一些改变,但是((样式)样式选择器)。其他的东西让我很困惑。再次感谢:)谢谢,这帮了我的忙。我还发现了一个链接到所有标准图标的页面,以防任何人需要标准图标的URL。
  <Placemark>
    <name>Isla de Roatan</name>
    <description>
       Cruise Stop        
    </description>
    <Style>
        <IconStyle>
            <Icon>
                <href>http://maps.google.com/mapfiles/kml/shapes/airports.png</href>
            </Icon>
        </IconStyle>
    </Style>
    <Point>
      <coordinates>-86.53,16.337461,0</coordinates>
    </Point>
  </Placemark>
Placemark placemark = ...;

Style myStyle = new Style().withId("my_style");
myStyle.withIconStyle(new IconStyle().withIcon(new Icon().withHref("http://someurl")));

placemark.addToStyleSelector(myStyle);
for (StyleSelector styleSelector : placemark.getStyleSelector())
{
    if (styleSelector.getId() == "my_style")
    {
        String href = ((Style)styleSelector).getIconStyle().getIcon().getHref();
    }
}