GithubHelp home page GithubHelp logo

digitalpenguin / locationresources Goto Github PK

View Code? Open in Web Editor NEW
5.0 4.0 3.0 566 KB

Google Maps Custom Resource Class Extra for MODX Revolution

PHP 32.60% CSS 0.78% JavaScript 65.00% Smarty 1.63%
modx-revolution extra custom-resources google-maps modx cms

locationresources's Introduction

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:

[[getResources?
    &parents=`18`
    &tpl=`myCustomTpl`
]]

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.

<div>
    <h4>[[+pagetitle]]</h4>
    <p>This chunk displays the values of this location resource.</p>
    <ul>
        <li>Latitude: [[+location_lat]]</li>
        <li>Longitude: [[+location_lng]]</li>
        <li>Zoom Level: [[+location_zoom]]</li>
        <li>Does the Map Have a Marker?: [[+location_has_marker]]</li>
        <li>Marker Latitude: [[+location_marker_lat]]</li>
        <li>Marker Longitude: [[+location_marker_lng]]</li>
        <li>Marker Title: [[+location_marker_title]]</li>
        <li>Marker Description: [[+location_marker_description]]</li>
        <li>Marker Link (href): [[+location_marker_link]]</li>
        <li>Marker Link Text : [[+location_marker_link_text]]</li>
    </ul>
</div>

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:

[[locationResourcesMap]]

This will display a map with all the default settings.

For customization, you can call the snippet with five parameters:

[[locationResourcesMap?
    &docid=`4`
    &parents=`3,42,50`
    &tpl=`myCustomTpl`
    &js=`myCustomJS` 
    &css=`myCustomDefaultCSS`
]]

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.

locationresources's People

Contributors

jako avatar jcdm avatar muzzwood avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

locationresources's Issues

modx 2.8.3 dont work

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 262144 bytes) in /home/merzae00/www/core/xpdo/om/xpdoobject.class.php on line 1755

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 262144 bytes) in /home/merzae00/www/core/xpdo/xpdo.class.php on line 749

Database update missed in upgrade path?

I recently updated to 1.2.1 from something before 1.2.

In the manager and in the front end I was seeing no map data. The front end was showing 'Error: resource did not contain an extended profile (ID:178)' while the manager was just coming up blank fields.

I could see the profile data being written the database table with each save but nothing seemed to be able to read it.

Checking the manager log I found the following:
[2017-07-11 12:37:33] (ERROR @ /www-root/core/xpdo/om/xpdoobject.class.php : 240) Error 42S22 executing statement: Array ( [0] => 42S22 [1] => 1054 [2] => Unknown column 'LocationProfile.marker_link_text' in 'field list' )

Which indicated that marker_link_text was missing from the database as a field. I added it manually and everything has 'snapped back' into place.

I wanted to flag this because somewhere in my upgrade path the field missed out on being added to the table so if that's something controllable from this end, then that should be patched somewhere in the next release.

Specify a default 'new map' state

Allow the develop to provide Lat/Long/Zoom settings (system settings?) to act as the default map state for new resources (rather than the 'whole world zoomed out' default used presently).

Unable to change standard resource to a location resource with the settings tab

A bug that slipped through in development.

LocationResources can be created ok via the resource tree.
Creating a new standard resource and changing the resource type to 'Location' on the settings tab before clicking save also works.

Problem is, if a default resource has already been created (it has been saved at least once), then if you try to change the resource type to 'Location' via the settings tab, it won't save.
Most likely a problem with the update processor.

Use OpenStreetMap instead of GoogleMap ?

Hi,

Since GoogleMap need API key, I'm looking for an alternative for using location place under MODX.
Do you think it could be possible to choose between several map rendering in a next version ?
OpenStreetMap as a very good API to make very usable free map :)

Have the map centre on the marker by default

When editing a location in the manager, to centre exactly on the marker seems to be a case of setting the marker and then copying and pasting the lat/long from the marker to the map fields.

I don't mind two separate lat/long values for map and marker because it allows for flexibility but it would be nice to have a 'centre map to marker' button or something to make it easy for clients to synchronise those values quickly.

Create lexicon strings reversed

v1.2.1

schermafbeelding 2017-07-11 om 15 58 11

schermafbeelding 2017-07-11 om 15 58 21

There's very little logic to why MODX has "Create a ... here" for one and not the other, but might as well try to be consistent with it for now :P

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.