LocationResources

Map Resources for MODX

Creator: Murray Wood (digitalpenguin)

Need help installing this extra?

About LocationResources

LocationResources is a basic integration between the Google Maps API and MODX Resources.

It allows drag and drop in the MODX manager to position maps and set markers which is then reflected on the web context (or others).

Information

Released
November 27, 2019

Supported Database
MySQL

License
GPLv2

Supported Versions
2.3 - Current

Downloads
4,817

Instructions

LocationResources

Google Maps Custom Resource Class Extra for MODX Revolution

LocationResources is a basic integration between the Google Maps API and MODX Resources. It allows drag and drop in the MODX manager to position maps and set markers which is then reflected on the web context (or others).

27/11/2019 - Version 1.4.0

NEW - Usage with getResources

Note: If you're not familiar with getResources, start with the "Normal Usage" instructions further below.

Make sure you have the getResources extra installed from the MODX package manager and your Google Maps API key is in the system settings. Create your location resource(s). Make a normal getResources snippet call and include your location resource(s).

For example if I have resource (id: 18) which is a parent and includes a list of location resources then I might call getResources like this:

Create a chunk called myCustomTpl or whatever you fancy.

Inside the chunk you can call the location values directly as placeholders with a location_ prefix.

<p> <p>This chunk displays the values of this location resource.</p> <ul> <li>Latitude: </li> <li>Longitude: </li> <li>Zoom Level: </li> <li>Does the Map Have a Marker?: </li> <li>Marker Latitude: </li> <li>Marker Longitude: </li> <li>Marker Title: </li> <li>Marker Description: </li> <li>Marker Link (href): </li> <li>Marker Link Text : </li> </ul> </p>

You can then of course display maps however you like using these values.

Normal Usage:

First add your Google Maps API Key into the system settings. Then, in the manager simply create a new resource of "Location" type. You will see the map displayed above the main resource content field. You can drag the map around and zoom to position it. You can choose to add a marker, position it and add an info window to it.

Remember to save the resource!

Then to have it displayed on your web context:

Call this snippet on any template/chunk attached to the LocationResource:

This will display a map with all the default settings. For customization, you can call the snippet with five parameters: ``` ``` Parameters ========== &docid - The ID of the resource you wish to pull for map display. Defaults to the current resource if not supplied. &tpl - Put the name of your custom chunk that contains the main map div. &js - Put the name of your custom chunk that contains the script to display the map. &css - Put the name of your custom chunk that contains your own css. (Or you can choose not to use default css in your system settings and style on your own). &parents - Accepts a comma-separated list of resource ids. If any children of that resource are LocationResources and have a marker set, those markers will be add via clustering top the map. This is in addition to the marker that belongs to the LocationResource controlling the main map. This marker will not be clustered. If you don't want it shown, you can remove it.

New in 1.4.0-pl

Changelog for LocationResources.

LocationResources 1.4.0 (27/11/2019)
  • Map values can now be accessed directly when using getResources! The fields can be used in a getResources tpl with the 'location_' prefix. - Thanks to @jako!

  • Updated readme.

LocationResources 1.3.2 (18/08/2017)
  • Fixed marker bug with quick create.

  • Removed all cluster code from output if not using clustering.

  • Fixed broken JS caused by /n and /r when using multiple lines for description

  • Fixed bug preventing map location to be set before initially saving resource.

LocationResources 1.3.1 (11/08/2017)
  • Fix pathing problem to cluster js file.

LocationResources 1.3.0 (11/08/2017)
  • Added marker cluster functionality to allow multiple markers on a single map. Values taken from selected LocationResources under specified parents.

  • Added &parents parameter that accepts a comma-separated list of resource ids with children containing markers.

  • Fixed lexicon values for creating via context menus in the resource tree.

  • Added checks to make sure profile record is populated with default values on create.

  • Changed marker description field to textarea to allow multi-line descriptions. (Kept same layout for now).

LocationResources 1.2.1 (08/07/2017)
  • Forces output of decimals to use dot notation. Some European locales were converting to commas and breaking the map.

LocationResources 1.2.0 (07/07/2017)
  • Revised layout in manager

  • Added geocoding functionality with a 'Find Address' search field.

  • Searching by address removes any current markers and adds a new marker at the found location.

  • Added a button that allows the user to centre the map to the marker if one has been added.

LocationResources 1.1.2 (24/03/2017)
  • Removed default values from xpdo schema. Default decimal values causing install errors when using a locale that uses commas instead.

  • 3 new system settings where map defaults are now stored. After install, the defaults can be set by the developer.

  • marker_link_test column added to database for future feature upgrade.

LocationResources 1.1.1 (21/03/2017)
  • Fixes div id generation for if the same map is called twice on a resource for some reason.

LocationResources 1.1.0 (19/03/2017)
  • Added serialisation to DIV so that map data can be loaded from other resources. This also allows multiple maps with snippets such as pdoTools or getResources.

  • Updated documentation

  • Added ID to error reports.

  • Added namespaced placeholder for docid.

  • Added class_key sanity check.

  • Make maps responsively scale to center. Big thanks to @jcdm (Josh Curtis) for the above additions!

  • Some aesthetic changes to service class code.

LocationResources 1.0.1
  • Fixed changing an existing standard resource into a Location Resource.

  • Fixed duplication of Location Resources.

  • Updated Lexicon text

LocationResources 1.0.0
  • Initial release.

Current releases

1.4.0-pl
View | Download
November 27, 2019
2.3 - Current

1.3.2-pl
View | Download
August 18, 2017
2.3 - Current