Search code examples
javakmljak

How to get LookAt data from KML file in Java


There is a tag called LookAt in the kml file. as below:

<LookAt>
        <longitude>51.36863708496094</longitude>
        <latitude>35.7291434559867</latitude>
        <altitude>0</altitude>
        <heading>0</heading>
        <tilt>0</tilt>
        <range>0</range>
        <altitudeMode>absolute</altitudeMode>
</LookAt>

I need to get the lat and long information of this tag. I also use the jak library. Can anyone help?


Solution

  • Thanks for the answer @CodeMonkey

    The final answer is as follows:

    Placemark placemark = (Placemark) folderFeature;
    AbstractView abstractView = placemark.getAbstractView();
       if (abstractView != null) {
            if (abstractView instanceof LookAt) {
                LookAt lookAt = (LookAt) abstractView;
                lookAt.getLatitude();
                lookAt.getLongitude();
             }
        }