Gmaps Fieldtype

Introduction

The official FieldType extension for the Gmaps module. Simply modify your Map from within your entry.

title

Installation

Prerequisites

Make sure your system meets the minimum requirements:

Installation Instructions

  1. Upload ee2/system/third_party/gmaps_ft to system/expressionengine/third_party/
  2. Upload ee2/system/themes/third_party/gmaps_ft to themes/third_party/
  3. Install the module in Add-Ons → Modules

Update instructions

  1. Backup the Files and the Database
  2. Remove all the old Gmaps Fieldtype files (both system and themes)
  3. Place the new files in the right folders
  4. Navigatie to the module page and hit the update trigger button

EE support

As of version 3.0.0 of EE, Gmaps for EE2 will not be extended with new features, but only with bugfixes.

The Gmaps Field

Once Gmaps FT is installed, you can add a Gmaps field to the Publish page by following these steps:

Publish page overview

When the custom field is created, you can see the Gmaps FT in action on the publish field

title

From here you can start adding markers, customize markers, search addresses and customize the map settings.

Editing Maps setting

To modify the settings for the Map, you can click in the top right on the 'map settings' button.

title

Search an address

To search an address, you can enter an address in the search form. If there is any result, they will be show below the form. From here you can add the address also to the map by clickin the plus sign.

title

Refresh the map

In some situations you mess up your map and you want to reset it. With the refresh map button, you can refresh your map to the saved version.

Reset the map

To simply reset/remove all your data on your map, just click the reset map button

Adding Markers (and others)

To add a marker, simply right click on the map. Now there will be a menu appear, where you can click on 'Add marker'.

title

Edit Markers (and others)

When you added some markers to your map, you can edit the markers by clicking on the edit icon in the top. Please notice that when you hover on the marker button in the top, the marker on the map will bounce so you can see which marker you are editing.

title

Removing markers (and others)

To remove the marker, you can click in the top on the delete icon. Or you can right click on a marker in the gmaps.

Field Tag

To show your created map, you can put your custom field tag inside a {exp:channel:entries} loop. This will show your map that you created from within the CP.

{your_custom_field}

To modify the map (like the map style or anything else) you can use the power of the Gmaps module. Simply extend your tag with some params from the {exp:gmaps:map} method

{your_custom_field width="100%"}

Please make sure you add the {exp:gmaps:init} to your template to include the necessary files

Tag params

The following tags are filled in from the entry self; map_type map_types latlng marker:icon:url marker:title

Tag Variable

Below are the Tag Variables. Those Variables can be used in the tag described above

marker:n:latlng

Show the latlng of one marker. {your_custom_field:marker:n:latlng}

marker:latlng

Show all latlng positions with pipeline`s

{your_custom_field:marker:latlng}

marker:n:title

Show the title for one marker

{your_custom_field:marker:n:title}

marker:title

Show all titles with pipeline`s

{your_custom_field:marker:title}

marker:n:icon

Show one icon

{your_custom_field:marker:n:icon}

marker:icon

Show all icons with pipeline`s

{your_custom_field:marker:icon}

route:from

Show the from latlng for use in the route function

{your_custom_field:route:from}

route:stops

Show the stops latlng for use in the route function

{your_custom_field:route:stops}

route:to

Show the to latlng for use in the route function

{your_custom_field:route:to}

has:markers

Variable that check if there is any marker set

{gmaps_field_extension:has:markers}

markers

Loop over the Markers

{gmaps_field_extension:markers}...{/gmaps_field_extension:markers}

markers:add_marker

Generate a {gmaps:add_marker} code. Place this inside a {exp:gmaps:map}....{/exp:gmaps:map} to the same marker to a front-end map.

{gmaps_field_extension:markers}{lat}{/gmaps_field_extension:markers}

markers:lat

The lat of the marker

{gmaps_field_extension:markers}{lat}{/gmaps_field_extension:markers}

markers:lng

The lng of the marker

{gmaps_field_extension:markers}{lng}{/gmaps_field_extension:markers}

markers:title

The title of the marker

{gmaps_field_extension:markers}{title}{/gmaps_field_extension:markers}

markers:icon

The icon of the marker

{gmaps_field_extension:markers}{icon}{/gmaps_field_extension:markers}

markers:content

The content of the infowindow

{gmaps_field_extension:markers}{content}{/gmaps_field_extension:markers}

markers:count

Holds the current number, started from 1

{gmaps_field_extension:markers}{count}{/gmaps_field_extension:markers}

markers:abs_count

Holds the current number, started from 0

{gmaps_field_extension:markers}{abs_count}{/gmaps_field_extension:markers}

markers:total_results

Show the total numbers of markers

{gmaps_field_extension:markers}{total_results}{/gmaps_field_extension:markers}

polyline:n:from

Get the from latlng form the n polyline

{gmaps_field_extension:polyline:1:from}

polyline:n:stops

Get the stops (latlng pipline seperated) from the n polyline to convert it to the route method

{gmaps_field_extension:polyline:1:stops}

polyline:n:to

Get the to latlng form the n polyline

{gmaps_field_extension:polyline:1:to}

polyline[OPTIONAL:N]

Loop over the polyline positions, where N is the number of the polyline created.

{gmapsfieldtype:polyline[OPTIONAL:1]}
    {stroke_color}
    {stroke_opacity}
    {stroke_weight}
    {path}
        {lat}, {lng}
    {/path}
{/gmapsfieldtype:polyline[OPTIONAL:1]}

polygon[OPTIONAL:N]

Loop over the polygons, where N is the number of the polygon created.

{gmapsfieldtype:polygon[OPTIONAL:1]}
    {stroke_color}
    {stroke_opacity}
    {stroke_weight}
    {fill_color}
    {fill_opacity}
    {path}
        {lat}, {lng}
    {/path}
{/gmapsfieldtype:polygon[OPTIONAL:1]}

circle[OPTIONAL:N]

Loop over the circles, where N is the number of the circle created.

{gmapsfieldtype:circle[OPTIONAL:1]}
    {stroke_color}
    {stroke_opacity}
    {stroke_weight}
    {fill_color}
    {fill_opacity}
    {lat}
    {lng}
    {radius}
{/gmapsfieldtype:circle[OPTIONAL:1]}

rectangle[OPTIONAL:N]

Loop over the circles, where N is the number of the circle created.

{gmapsfieldtype:rectangle[OPTIONAL:1]}
    {stroke_color}
    {stroke_opacity}
    {stroke_weight}
    {fill_color}
    {fill_opacity}
    {bounds}
        {lng}
        {lng}
    {/bounds}
{/gmapsfieldtype:rectangle[OPTIONAL:1]}

map

Get all map variables

{gmapsfieldtype:map}
    {map_types}
    {map_type}
    {zoom_level}
    {scroll_wheel}
    {zoom_control}
    {zoom_control_style}
    {zoom_control_position}
    {pan_control}
    {pan_control_position}
    {map_type_control}
    {map_type_control_style}
    {map_type_control_position}
    {street_view_control}
    {street_view_control_position}
    {google_overlay_html}
    {google_overlay_position}
    {center}
{/gmapsfieldtype:map}

Channel Form

The Gmap Fieldtype will "almost" perfectly work in combination with the Channel Form (formally SafeCracker). But in some case, when you modify the logic or button, or you use ajax to submit your form, the Gmaps Fieldtype will be a little bit confused.

In that case, there is a JS method availble that push the Gmaps Fieldtype back.

Tag Parameters

Below are the Tag Parameters. Those parameters can be used in the tag described above

save_settings

Manually save the settings for the fieldtype.

$('#[ID-OF-YOUR-CHANNEL-FORM] input[type="submit"]').click(function(){
    $('.gmap_holder').each(function(){
        EE_GMAPS_FT.save_settings($(this));
    });
});

Supported

The Fieldtype supports the following modules and extension

Content Elements

{exp:gmaps:init}

{exp:channel:entries entry_id="1" dynamic="no"}
    {ce_field}
        {gmaps_fieldtype}
               {value}
        {/gmaps_fieldtype}
    {/ce_field}
{/exp:channel:entries}

Webservice

The Gmaps Fieldtype supports all methods of the Entry API.

To import a new data map via the Entry API, you have to use the following data structure.

array('gmaps_field' => array(
    'markers' => array(
        array(
            'lat' =>'52.3909176',
            'lng' =>'6.049638',
            'title' => 'test',
            'icon' => null
        )
    ),
    'map' => array(
        'map_type' => 'roadmap',
        'map_types' => array(
            'hybrid',
            'roadmap',
            'satellite',
            'terrain'
        )
    ),
    'polylines' => array(),
    'polygons' => array(),

));

Extra params bug

At the moment it is not possible to use enters in your custom field like below;

{custom_field
   param1=""
   param2=""
   param3=""
}

Instead of that you have to use it the following way;

{custom_field param1="" param2="" param3=""}

See also http://expressionengine.stackexchange.com/questions/10726/custom-field-with-params-and-enters or https://support.ellislab.com/bugs/detail/19434

Hooks

gmaps_fieldtype_save_data

(added in v3.0.8)

 ee()->extensions->call('gmaps_fieldtype_save_data', $data, $entry_id, $field_id);

Changelog

3.3.1 (00-00-2017)

3.3.0 (18-01-2017)

3.2.0 (23-11-2016)

3.1.1 (11-11-2016)

3.1.0 (04-04-2016)

3.0.10 (25-08-2016)

3.0.9 (11-08-2016)

3.0.8 (01-08-2016)

3.0.7 (14-07-2016)

3.0.6 (11-07-2016)

3.0.5 (20-06-2016)

3.0.3 (06-06-2016)

3.0.2

3.0.1

3.0.0

2.1.4

2.1.3

2.1.2

2.1.1

2.1.0

2.0.3

2.0.2

2.0.1

2.0

1.8

1.7

1.6.3

1.6.2

1.6.1

1.6

1.5.2

1.5.1

1.5

1.4.4

1.4.3

1.4.2

1.4.1

1.4

1.3

1.2.3

1.2.2

1.2.1

1.2

1.1.1

1.1

1.0