From 5acbe330e5eba7c7be9de7342bfb63def038fdbd Mon Sep 17 00:00:00 2001 From: "mathieu.kergall@gmail.com" Date: Tue, 31 Dec 2013 11:27:13 +0000 Subject: [PATCH] KML bug fixing. Support inline Styles --- .../src/org/osmdroid/bonuspack/kml/KmlDocument.java | 10 +++++++++- .../src/org/osmdroid/bonuspack/kml/KmlObject.java | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/OSMBonusPack/src/org/osmdroid/bonuspack/kml/KmlDocument.java b/OSMBonusPack/src/org/osmdroid/bonuspack/kml/KmlDocument.java index c6e49d7f..1ebb0446 100644 --- a/OSMBonusPack/src/org/osmdroid/bonuspack/kml/KmlDocument.java +++ b/OSMBonusPack/src/org/osmdroid/bonuspack/kml/KmlDocument.java @@ -315,7 +315,15 @@ public void endElement(String uri, String localName, String name) if (mCurrentStyle != null && mCurrentStyle.iconColorStyle != null) mCurrentStyle.iconHref = mString; } else if (localName.equals("Style")){ - putStyle(mCurrentStyleId, mCurrentStyle); + if (mCurrentStyleId != null) + putStyle(mCurrentStyleId, mCurrentStyle); + else { + mCurrentStyleId = addStyle(mCurrentStyle); + if (mKmlCurrentObject != null){ + //this is an inline style. Set its style id to the KmlObject container: + mKmlCurrentObject.mStyle = mCurrentStyleId; + } + } mCurrentStyle = null; } } diff --git a/OSMBonusPack/src/org/osmdroid/bonuspack/kml/KmlObject.java b/OSMBonusPack/src/org/osmdroid/bonuspack/kml/KmlObject.java index edb7c529..a39bcc29 100644 --- a/OSMBonusPack/src/org/osmdroid/bonuspack/kml/KmlObject.java +++ b/OSMBonusPack/src/org/osmdroid/bonuspack/kml/KmlObject.java @@ -298,7 +298,7 @@ public Overlay buildOverlays(Context context, MapView map, Drawable marker, KmlD polygonOverlay.setPoints(mCoordinates); polygonOverlay.setTitle(mName); polygonOverlay.setSnippet(mDescription); - if (!mName.equals("") || !mDescription.equals("")){ + if ((mName!=null && !"".equals(mName)) || (mDescription!=null && !"".equals(mDescription))){ String packageName = context.getPackageName(); int layoutResId = context.getResources().getIdentifier("layout/bonuspack_bubble", null, packageName); polygonOverlay.setInfoWindow(layoutResId, map);