Skip to content

Commit

Permalink
Merge pull request #293 from stephenmcd/kml-draw-order
Browse files Browse the repository at this point in the history
Kml draw order
  • Loading branch information
samthor authored Jul 11, 2016
2 parents b153c67 + 56426b7 commit 92987df
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dependencies {
compile project(':library')
// Or, fetch from Maven:
// compile 'com.google.maps.android:android-maps-utils:0.3+'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-maps:9.2.0'
}

android {
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ archivesBaseName = 'android-maps-utils'
group = 'com.google.maps.android'

dependencies {
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-maps:9.2.0'
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

private final static int LATITUDE_INDEX = 1;

private final static String PROPERTY_REGEX = "name|description|visibility|open|address|phoneNumber";
private final static String PROPERTY_REGEX = "name|description|drawOrder|visibility|open|address|phoneNumber";

private final static String BOUNDARY_REGEX = "outerBoundaryIs|innerBoundaryIs";

Expand Down
24 changes: 22 additions & 2 deletions library/src/com/google/maps/android/kml/KmlRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ private void addPlacemarksToMap(HashMap<KmlPlacemark, Object> placemarks) {
* @return Google Map Object of the placemark geometry after it has been added to the map.
*/
private Object addPlacemarkToMap(KmlPlacemark placemark, boolean placemarkVisibility) {
//If the placemark contains a geometry, then we add it to the map
//If it doesnt contain a geometry, we do not add anything to the map and just store values
// If the placemark contains a geometry, then we add it to the map. If it doesn't
// contain a geometry, we do not add anything to the map, and just store values.
if (placemark.getGeometry() != null) {
String placemarkId = placemark.getStyleId();
KmlGeometry geometry = placemark.getGeometry();
Expand Down Expand Up @@ -482,17 +482,37 @@ private Object addToMap(KmlPlacemark placemark, KmlGeometry geometry, KmlStyle s
KmlStyle inlineStyle, boolean isVisible) {

String geometryType = geometry.getGeometryType();
boolean hasDrawOrder = placemark.hasProperty("drawOrder");
float drawOrder = 0;

if (hasDrawOrder) {
try {
drawOrder = Float.parseFloat(placemark.getProperty("drawOrder"));
} catch (NumberFormatException e) {
hasDrawOrder = false;
}
}

if (geometryType.equals("Point")) {
Marker marker = addPointToMap(placemark, (KmlPoint) geometry, style, inlineStyle);
marker.setVisible(isVisible);
if (hasDrawOrder) {
marker.setZIndex(drawOrder);
}
return marker;
} else if (geometryType.equals("LineString")) {
Polyline polyline = addLineStringToMap((KmlLineString) geometry, style, inlineStyle);
polyline.setVisible(isVisible);
if (hasDrawOrder) {
polyline.setZIndex(drawOrder);
}
return polyline;
} else if (geometryType.equals("Polygon")) {
Polygon polygon = addPolygonToMap((KmlPolygon) geometry, style, inlineStyle);
polygon.setVisible(isVisible);
if (hasDrawOrder) {
polygon.setZIndex(drawOrder);
}
return polygon;
} else if (geometryType.equals("MultiGeometry")) {
return addMultiGeometryToMap(placemark, (KmlMultiGeometry) geometry, style, inlineStyle,
Expand Down

0 comments on commit 92987df

Please sign in to comment.