X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/081fd3863698a273eb468cceec84cc0cffb10261..67ebaf15d77cb00e0be16696c60860e7c61e827f:/IkiWiki/Plugin/osm.pm diff --git a/IkiWiki/Plugin/osm.pm b/IkiWiki/Plugin/osm.pm index 4c50fec53..a7baa5f2b 100644 --- a/IkiWiki/Plugin/osm.pm +++ b/IkiWiki/Plugin/osm.pm @@ -69,17 +69,8 @@ sub getsetup () { }, osm_layers => { type => "string", - example => { OSM => 1, - Google => 'Hybrid', - }, - description => "Layers to use in the map. If the value is 1, use the default for the map, otherwise the argument is a URL (for OSM layers, e.g. http://a.tile.stamen.com/toner/\${z}/\${x}/\${y}.png) or a type option for Google maps (Normal, Satellite, Hybrid or Physical).", - safe => 0, - rebuild => 1, - }, - osm_layers_order => { - type => "string", - example => { 'OSM', 'Google' }, - description => "Display order for the layers. The first layer is the default layer, must match exactly the left side of the osm_layers hash.", + example => { 'OSM', 'GoogleSatellite' }, + description => "Layers to use in the map. Can be either the 'OSM' string or a type option for Google maps (GoogleNormal, GoogleSatellite, GoogleHybrid or GooglePhysical). It can also be an arbitrary URL in a syntax acceptable for OpenLayers.Layer.OSM.url parameter.", safe => 0, rebuild => 1, }, @@ -368,23 +359,29 @@ sub writekml($;$) { foreach my $map (keys %waypoints) { my $output; my $writer = XML::Writer->new( OUTPUT => \$output, - DATA_MODE => 1, ENCODING => 'UTF-8'); + DATA_MODE => 1, DATA_INDENT => ' ', ENCODING => 'UTF-8'); $writer->xmlDecl(); $writer->startTag("kml", "xmlns" => "http://www.opengis.net/kml/2.2"); $writer->startTag("Document"); # first pass: get the icons + my %tags_map = (); # keep track of tags seen foreach my $name (keys %{$waypoints{$map}}) { my %options = %{$waypoints{$map}{$name}}; - $writer->startTag("Style", id => $options{tag}); - $writer->startTag("IconStyle"); - $writer->startTag("Icon"); - $writer->startTag("href"); - $writer->characters($options{icon}); - $writer->endTag(); - $writer->endTag(); - $writer->endTag(); - $writer->endTag(); + if (!$tags_map{$options{tag}}) { + debug("found new style " . $options{tag}); + $tags_map{$options{tag}} = (); + $writer->startTag("Style", id => $options{tag}); + $writer->startTag("IconStyle"); + $writer->startTag("Icon"); + $writer->startTag("href"); + $writer->characters($options{icon}); + $writer->endTag(); + $writer->endTag(); + $writer->endTag(); + $writer->endTag(); + } + $tags_map{$options{tag}}{$name} = \%options; } foreach my $name (keys %{$waypoints{$map}}) { @@ -590,7 +587,6 @@ sub map_setup_code($;@) { $options{'mapurl'} = $mapurl; } $options{'layers'} = $config{osm_layers}; - $options{'layers_order'} = $config{osm_layers_order}; return "mapsetup('mapdiv-$name', " . to_json(\%options) . ");"; }