MKergall / osmbonuspack

A third-party library of (very) useful additional objects for osmdroid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to give each icon its own style in kml structure

erco99 opened this issue · comments

Hi, i'm developing an app which allows you to drag markers on the map and then save it in a kml document. The problem is that each marker may have a different icon, so i'm trying to define a structure like this:

<Style id="icon-1399-normal">
    <IconStyle>
        <scale>1.1</scale>
        <Icon>
          <href>https://www.gstatic.com/mapspro/images/stock/1399-rec-viewing-platform.png</href>
        </Icon>
    </IconStyle>
      <LabelStyle>
        <scale>0</scale>
      </LabelStyle>
</Style> 
     ...
<Placemark>
     <name>Tour Eiffel</name>
     <description>description</description>
     <styleUrl>#icon-1399-normal</styleUrl>
        <Point>
          <coordinates>
            2.29790210723877,48.8560469728205,0
          </coordinates>
        </Point>
</Placemark>

Something like: define different styles, and then apply one of them to the several placemarks below.
With the tutorial number 4 i couldn't figure out how to make this.

The main point of the problem is that in this piece of code

@Override public void onPoint(Marker marker, KmlPlacemark kmlPlacemark, KmlPoint kmlPoint) {
  if ("panda_area".equals(kmlPlacemark.getExtendedData("category")))
    kmlPlacemark.mStyle = "panda_area";
  kmlPoint.applyDefaultStyling(marker, mDefaultStyle, kmlPlacemark, mKmlDocument, map);
}

in chapter 13.3, kmlPlacemark.getExtendedData("category") returns null.
There's no explanation of how to give single placemarks a category and a style.

commented

When creating your kmlPlacemark, you could do:
kmlPlacemark.setExtendedData("category", "panda_area");

Even simpler, as you create the placemarks programmatically, just set the appropriate style directly when you create a new placemark:
kmlPlacemark.mStyle = "icon-1399-normal";

Creating a Style is described in 13.3.

P.S. Requests for help, on StackOverflow, please.

I'll try implementing it this way.
If i still have issues, i'll ask for help on stackoverflow.
Thank you!

In case you didn't see it on stackoverflow, i updated the question. My issue is still the same, i hope it is not a bug.