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.
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!
@MKergall i posted a question on stackoverflow: https://stackoverflow.com/questions/67566642/osmbonuspack-unable-to-assign-each-marker-its-own-style-in-kml-structure
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.