Skip to content

Commit

Permalink
Merge pull request #1 from BramVan-Oosterhout/Item14397
Browse files Browse the repository at this point in the history
Item14397: merging into master
  • Loading branch information
MichaelDaum committed Jun 20, 2017
2 parents 7f2e653 + 995cdbc commit bdc8cce
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 40 deletions.
84 changes: 55 additions & 29 deletions data/System/GoogleMapsPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1468241409" format="1.1" version="1"}%
%META:TOPICINFO{author="BramVanOosterhout" comment="" date="1495161447" format="1.1" reprev="4" version="6"}%
---+!! %TOPIC%
%FORMFIELD{"Description"}%

Expand All @@ -11,24 +11,29 @@ You type:

<verbatim class="tml">
%GOOGLEMAPS{
height="350px"
width="600px"
zoom="15"
address="Union Station, Los Angeles, USA"
infowindowaddress="Union Station, Los Angeles, USA"
infowindow="<b>Here it is!</b>"
address="Nebraska"
zoom="4"
markeraddress="Hanford
Oak Ridge=
Stagg Field Chicago=Stagg Field Chicago Uni,The location of the the Pile-1 first reaction.,There is not much left here.
Bradbury Science Museum, Los Alamos=
White Sands Missile Range=White Sands Missile Range,The location of the Trinity test"
id="ManhattanProject"
}%
</verbatim>

<verbatim class="foswikiHidden">
%STARTSECTION{"example1"}%
%GOOGLEMAPS{
height="350px"
width="600px"
zoom="15"
address="Union Station, Los Angeles, USA"
infowindowaddress="Union Station, Los Angeles, USA"
infowindow="<b>Here it is!</b>"
address="Nebraska"
zoom="4"
markeraddress="Hanford
Oak Ridge=
Stagg Field Chicago=Stagg Field Chicago Uni,The location of the the Pile-1 first reaction.,There is not much left here.
Bradbury Science Museum, Los Alamos=
White Sands Missile Range=White Sands Missile Range,The location of the Trinity test"
}%
%ENDSECTION{"example1"}%
</verbatim>
Expand All @@ -37,7 +42,7 @@ You get (if installed):

%IF{"context GoogleMapsPluginEnabled"
then="$percntINCLUDE{\"%WEB%.%TOPIC%\" section=\"example1\"}$percnt"
else="<img src='%ATTACHURLPATH%/GoogleMapsSnap1.png' />"
else="<img src='%ATTACHURLPATH%/TheManhattanProject.jpg' width='599' height='352' />"
}%

---+++ !JavaScript example
Expand All @@ -47,6 +52,7 @@ while opening up a few more possibilities.

%IF{"context GoogleMapsPluginEnabled"
then="$percntINCLUDE{\"%WEB%.%TOPIC%\" section=\"example2\"}$percnt"
else="<img src="%ATTACHURLPATH%/JavaScriptExample.jpg" alt="JavaScriptExample.jpg" width='450' height='395' />"
}%

<verbatim class="foswikiHidden">
Expand Down Expand Up @@ -181,23 +187,36 @@ while opening up a few more possibilities.

---++ Syntax

=%<nop>GOOGLEMAPS{...}%=

* address: free form address to center the map on
* center: comma-separated latitude and longitude position to center the map on, e.g. =53, 9= (use either =address= or =center=);
* zoom: integer zoom factor
* markeraddress: addresses of markers to be displayed on the map; addresses are separated by newlines
* infowindow: content of the info window to be displayed at the marker, or at the =infowindowaddress=
* infowindowaddress: position where to put the infowindow
* infowindowposition: coma-separated latitude and longitude position of the infowindow (use either =infowindowaddress= or =infowindowposition=);
* type: map type, can be =roadmap=, =sattelite=, =hybrid= or =terrain=
* typecontrol: boolean flag whether to display the type control widget
* navigationcontrol: boolean flag whether to display the navigation control
* streetviewcontrol: boolean flag whether to display the streetview control
* scrollwheel: boolean flag whether to enable/disable zooming using the scroll wheel
* height: height of the map (%RED%required%ENDCOLOR%)
* width: width of the map, defaults to 100% expanding to the size of the container
* id: the html id of the container holding the map, defaults to a random id
| *%<nop>GOOGLEMAPS{...}%* |||
| *Parameter* | *Description* | *Default* |
| =height="..."= | integer zoom factor | 350px |
| =width="..."= | integer zoom factor | |
| =zoom="..."= | integer zoom factor | 1 |
| =markeraddress="..."= | addresses of markers to be displayed on the map; addresses are separated by newlines <br />\
See [[#DetailsForMarkerAddress][examples]] below. | |
| =infowindow="..."= | content of the info window to be displayed at the marker, or at the =infowindowaddress= | |
| _use either =address= or =center=._ ||
| =address="..."= | free form address to center the map on | |
| =center="..."= | comma-separated latitude and longitude position to center the map on, e.g. =53, 9= | |
| _use either =infowindowaddress= or =infowindowposition=._ |||
| =infowindowaddress="..."= | position where to put the infowindow | |
| =infowindowposition="..."= | coma-separated latitude and longitude position of the infowindow | |
| =type="..."= | map type, can be =roadmap=, =satellite=, =hybrid= or =terrain= | =roadmap= |
| =typecontrol="on,off"= | boolean flag whether to display the type control widget | =on= |
| =navigationcontrol="on,off"= | boolean flag whether to display the navigation control | =on= |
| =streetviewcontrol="on,off"= | boolean flag whether to display the streetview control | =on= |
| =scrollwheel="on,off"= | boolean flag whether to enable/disable zooming using the scroll wheel | =on= |
| =id="..."= | the html id of the container holding the map, defaults to a random id | =gmap3&lt;random>= |

#DetailsForMarkerAddress
---+++ Details for the =markeraddress=
=markeraddress= accepts three different formats:
| *Format* | *Example* | *Result* |
| A location | Hanford | <img src="%ATTACHURLPATH%/TheHanfordSite.jpg" alt="TheHanfordSite.jpg" width='133' height='122' /> |
| A location followed by an equal sign (=) | Oak Ridge= | <img src="%ATTACHURLPATH%/TheOakRidgeSite.jpg" alt="TheOakRidgeSite.jpg" width='351' height='128' /> |
| A location and a description, separated by an equal sign | White Sands Missile Range=White Sands Missile Range,The location of the Trinity test. <p />\
<b>Note:</b> the comma introduces a new line. | <img src="%ATTACHURLPATH%/TheTrinityTestSite.jpg" alt="TheTrinityTestSite.jpg" width='233' height='133' /> |


---++ Further reading

Expand Down Expand Up @@ -227,6 +246,8 @@ If you are using [[Foswiki:Extensions/SecurityHeadersPlugin][SecurityHeadersPlug
| 08 Feb 2013: | initial release |




%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="Michael Daum"}%
%META:FIELD{name="Version" title="Version" value="%25$VERSION%25"}%
Expand All @@ -239,3 +260,8 @@ If you are using [[Foswiki:Extensions/SecurityHeadersPlugin][SecurityHeadersPlug
%META:FIELD{name="Support" title="Support" value="Foswiki:Support/%25TOPIC%25"}%
%META:FILEATTACHMENT{name="GoogleMapsSnap1.png" attachment="GoogleMapsSnap1.png" attr="" comment="" date="1468241409" size="270907" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="script.js" attachment="script.js" attr="" comment="Generated by <nop>AttachContentPlugin" date="1468241409" path="script.js" size="2705" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="TheHanfordSite.jpg" attachment="TheHanfordSite.jpg" attr="" comment="The Hanford site" date="1494650666" path="TheHanfordSite.jpg" size="11767" user="BramVanOosterhout" version="1"}%
%META:FILEATTACHMENT{name="TheOakRidgeSite.jpg" attachment="TheOakRidgeSite.jpg" attr="" comment="The Oak Ridge site" date="1494650698" path="TheOakRidgeSite.jpg" size="19369" user="BramVanOosterhout" version="1"}%
%META:FILEATTACHMENT{name="TheTrinityTestSite.jpg" attachment="TheTrinityTestSite.jpg" attr="" comment="The Trinity test site" date="1494650726" path="TheTrinityTestSite.jpg" size="16415" user="BramVanOosterhout" version="1"}%
%META:FILEATTACHMENT{name="TheManhattanProject.jpg" attachment="TheManhattanProject.jpg" attr="" comment="The Manhattan project map" date="1494650754" path="TheManhattanProject.jpg" size="54727" user="BramVanOosterhout" version="1"}%
%META:FILEATTACHMENT{name="JavaScriptExample.jpg" attachment="JavaScriptExample.jpg" attr="" comment="JavaScript example" date="1494653037" path="JavaScriptExample.jpg" size="46313" user="BramVanOosterhout" version="1"}%
13 changes: 8 additions & 5 deletions lib/Foswiki/Plugins/GoogleMapsPlugin/Core.pm
Expand Up @@ -81,11 +81,14 @@ sub GOOGLEMAPS {
my $zoom = $params->{zoom} || 1;
$opts{map}{options}{zoom} = int($zoom);

my $markerAddress = $params->{markeraddress};
if (defined $markerAddress) {
foreach my $address (split(/\s*[\n;]\s*/, $markerAddress)) {
my @address = split(/\s*,\s*/, $address);
push @{$opts{marker}{values}}, {address => $address}
my $markerValuesParam = $params->{markeraddress};
if (defined $markerValuesParam) {
foreach my $marker (split(/\s*[\n;]\s*/, $markerValuesParam)) {
my ($address, $data) = split(/\s*=\s*/, $marker);
unless ( $data ) {
$data = $address unless ( $marker =~ m/=/ );
}
push(@{$opts{marker}{values}}, {address => $address, data => $data});
}
}

Expand Down
Binary file added pub/System/GoogleMapsPlugin/JavaScriptExample.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pub/System/GoogleMapsPlugin/TheHanfordSite.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pub/System/GoogleMapsPlugin/TheOakRidgeSite.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 5 additions & 6 deletions pub/System/GoogleMapsPlugin/pkg.uncompressed.js
Expand Up @@ -2563,15 +2563,15 @@ jQuery(function($) {
opts = $this.data();

if (typeof(opts.marker) !== 'undefined') {
$.each(opts.marker.values, function(index, item) {

opts.marker.events = {
"click": function(marker) {
"click": function(marker,event,context) {
var $this = $(this),
infowindow = $this.gmap3({get:{name:"infowindow"}}),
content;
if (item.address) {
content = item.address.replace(/, */g, '<br />');

if (context.data) {
content = context.data.replace(/, */g, '<br />');

if (infowindow) {
infowindow.open($this.gmap3("get"), marker);
Expand Down Expand Up @@ -2608,7 +2608,6 @@ jQuery(function($) {
}
}
};
});
}


Expand Down

0 comments on commit bdc8cce

Please sign in to comment.