Widget talk:KMLsidebarmap

From Transit.Wiki

There are very few examples of sidebar for Google Maps in Mediawiki (Tetherless Map and SIMILE Exhibit all of them have been 3 iscontinued/outdated, and there's none for specifically for version 3.

For now I've developed a widget that would parse KML files and display them on a Google Map along with a sidebar. It uses parser called GeoXML v3, which is different from GeoXml3.

This is not a typical widget because it requires several files to be uploaded. In the long run, it ought to be a full extension by itself. However a widget provides a rapid development without having to know a lot about php. If you have time to convert it into an extension, please go ahead for it.

The required files are located here: https://apps.transitunlimited.org/files/geoxml-v3-mw.zip

Installation steps

  1. Install Widgets extension.
  2. Unzip the files and upload them into the extensions directory, like other MW extensions.
  3. Copy the source of this file and create a page of the same name.

Usage

Place these statements into the wiki page:

{{#Widget:KMLsidebarmap
|file=<link to the kml file>
|file=<link to the 2nd kml file if available>
|defaultmap=true
}}

Parameters

  • file - Absolute or relative link to the file name. It can also get information from an Semantic Mediawiki Query with output to KML. To do so, begin file name with index.php and then continue with the output string to kml. If the output string can be parsed at the Google Maps web site, it should be able to be parsed here.
  • alticon - If the KML file doesn't specify an icon (like kml output from SMW), it defaults to an ugly icon. This parameter allows an alterate icon of 32 x 32px be chosen to replace the default icon, but only one can be specified. If you want to have different icons on the map, make sure the KML file has multiple icons specified.
  • infowindowwidth - Width of the infowindow (default is 250px).
  • defaultmap (T/F) - If this parameter is selected true, no other statement is necessary to create a map with sidebar.
  • sidebarwidth - width of the default sidebar
  • sidebarfloat - location of default sidebar. Default is left.
  • mapwidth - width of default map.

For styling purposes, you can forego the default map and create a map by specifying the DIVs. This allows you to have a stronger control and able to have different look based on whether it is viewed on a desktop computer or a mobile device. To generate a map, following DIVs must be included below the widget:

<div id="sidebar" class=xxx  style="width:xxx px; height:xxx ;overflow:auto;"></div>
<div id="map_canvas" class=xxx  style=" width:xxx ; height:xxx ;"></div>

This widget allows the use of a proxy (also included in the files) to allow external files to be parsed, which normally is not permitted by default for security purposes. To prevent abuse, the proxy also has safeguards that restrict certain web sites or files to be processed. To change that setting, open the proxy.php file and edit $validurls =

The default only allows files with kml extension and anything from maps.google.com. It will not parse anything else. You can change the default to include only the sites that you approved of, or include other file types.

Example

{{#Widget:KMLsidebarmap
|file=index.php?title=Special%3AAsk&q=[[City%3A%3AOakland]]%0D%0A[[Category%3ARail+stations]]&po=%3FLatlong&eq=yes&p[format]=kml&p[title]=/Rail stations
|alticon=http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png
|defaultmap=true
}}

Comments

blog comments powered by Disqus