Contents

Map - Plugixa Car Rental

Map PRO draws your locations on a Google map, in two places:

  • A locator page. The [plugixa_car_rental_map] shortcode shows your desks on a map with a searchable list beside it. Each desk shows whether it is open now, its lowest daily price, a Book here button that opens the booking form with that desk chosen, and Directions.
  • The booking form. The form’s first step can show the pickup desks on a map, so a customer chooses where to pick the car up by clicking a pin or a card.

The locator with a search field, a Near me button and “3 rental desks” above cards for Airport Terminal 2, Cascais Marina and City Centre, each with its address, “Open now” and its closing time, “from €29.00 / day”, Book here and Directions, beside a map of Lisbon with a €29 pin on each desk

Map is an app, on by default in Pro. Nothing is drawn until you save a Google Maps API key and give your locations coordinates. If the Map section is missing from Settings, switch on Map in the App manager.

Setting it up

  1. In the Google Cloud console, create an API key with the Maps JavaScript API enabled, on a project with billing set up. Under the key’s restrictions, choose Websites and add your site’s address, for example https://example.com/*.
  2. Open Plugixa Car Rental -> Settings -> Map, paste the key into Google Maps API key (browser) and click Save.
  3. Give each location a Latitude and a Longitude. See Locations.
  4. Put [plugixa_car_rental_map] on a page. The booking form’s map needs no step of its own: it appears in the form once two or more pickup desks have coordinates.

This key is not the one used by Delivery and collection. Delivery’s key is used by your server and kept secret. The map’s key is used by the visitor’s browser, so it needs a website restriction instead.

The Map settings

The Map section of Settings with Show maps on the site switched on, the Google Maps API key (browser) field, the shortcode to copy, the switch Show a map to choose the pickup desk in the booking form, Map style Muted, Locator layout List beside the map, an empty Pin colour field with a blue swatch, and a note about privacy

Field Default What it does
Show maps on the site On The main switch. Off hides every map: the shortcode prints nothing and the booking form shows no map. Your other settings are kept.
Google Maps API key (browser) Empty “A key with the Maps JavaScript API turned on, restricted to this website’s address.” Without it no map is drawn anywhere. Spaces and any character a Google key cannot contain are removed when you save.
Place the locator on any page with this shortcode: [plugixa_car_rental_map] Read-only, with a copy button.
Show a map to choose the pickup desk in the booking form On Adds the map to the first step of the booking form. “Only when the form offers two or more desks that have coordinates.” Off keeps the locator shortcode working and leaves the form as it is.
Map style Muted How the base map looks, for every map on the site. Muted is soft grey with shops, other places of interest and public transport hidden. Light is paler than Google’s own map with businesses hidden. Dark is a dark map. Google default is Google’s normal map. A shortcode can choose another with style.
Locator layout List beside the map The layout of the shortcode: List beside the map or Map only. A shortcode can choose another with layout. The booking form’s map always has its list.
Pin colour Empty The colour of the pins, the selected card’s outline and the buttons on the maps. “Empty uses the booking form’s accent colour”, set under Booking form style. Pick a colour with the swatch or type it as #1d3fbf.

The note at the bottom of the section reads “A page with a map loads Google’s map script in the visitor’s browser, which sends Google their IP address and the page’s address. Mention Google Maps in your privacy policy.”

The key is not treated as a secret. It is shown in the field after saving, and anyone who views the source of a page with a map can read it, because the visitor’s browser has to send it to Google. That is how Google Maps keys work. Protect it in the Google Cloud console by restricting it to your site’s address and to the Maps JavaScript API.

The shortcode

[plugixa_car_rental_map]
Attribute Default What it does
height 560 The height of the map in pixels, a number without px. Anything below 240 is raised to 240 and anything above 1600 is lowered to 1600.
zoom 13 The zoom level, from 1 to 20, used when a single desk is shown.
layout The Locator layout setting list for the list beside the map, map for the map alone.
style The Map style setting muted, light, dark or google.
search yes no (or false, 0, off) hides the search field and Near me above the list.
page Found by itself The address of the page with the booking form, for the Book here buttons. See Book here.
[plugixa_car_rental_map height="480" layout="map" style="dark"]
[plugixa_car_rental_map search="no" page="https://example.com/book-a-car/"]

A value that is not on the list falls back to the first one: list for layout, muted for style.

Things to know about the attributes:

  • zoom only matters when one desk is shown, at first or after a search that leaves one. With two or more, the map fits itself around them and the zoom follows from that.
  • search only matters with the list. A map layout has no list, so it has no search field, no Near me and no count.
  • Each map on a page keeps its own height, so two maps on one page can differ.
  • On a narrow screen the map is never taller than most of the screen, whatever height says, so the page can still be scrolled.

There is no attribute for choosing locations. Every map shows the same desks.

What the map shows

A location is on the map when all of these are true:

Condition Detail
It is published Unpublished and trashed locations are left out.
It takes pickups or returns A location that does neither is left out. A return-only desk is shown, without Book here.
It has coordinates Both Latitude and Longitude are filled in. The plugin does not look them up from the address.

The list follows the order of your locations, set by their Order number and then their name.

The cards and the pins

Each desk has a card in the list, with a car icon, its name, its address (the street, city and country), its opening state and its price.

Item What it shows
Opening state Worked out in the visitor’s browser when the page opens, at the desk’s own timezone: “Open now · Closes 19:00”, “Closed · Opens 08:00”, “Closed”, or “Open 24 hours” for a desk open 00:00 to 24:00. A desk with a lunch break is “Closed · Opens 14:00” during the break. A closure in the next eight days shows that day as “Closed”.
Price “from €29.00 / day”: the lowest daily rate of any published rate for a published model at that desk, in any length-of-rental bracket, so usually your weekly rate. A rate for this one location replaces the all-locations rates of that model. Pricing rules, tax and extras are not included. A desk with no rate shows no price.
Book here Opens the booking form with the desk chosen. Only on desks that take pickups.
Directions Opens Google Maps in a new tab with directions to the desk.

On the map, each desk is a pin showing its price, such as €29, or a plain dot when it has no price. Pins that come close together are drawn as one round pin with a number. Clicking it zooms in until they separate. From a close zoom on, every desk has its own pin.

Choosing a desk

The same locator with City Centre chosen: its card is outlined in the list and a popup on the map shows City Centre, Avenida da Liberdade 120, Lisbon, Portugal, Open now · Closes 19:00, from €29.00 / day, Book here and Directions, with a close button

Clicking a card or a pin chooses that desk: its card is outlined, its pin is filled in, and the map moves to it with a popup showing the card. Hovering a card lights up its pin. Clicking elsewhere on the map, pressing Esc or the popup’s close button closes the popup.

When the locator is less than 720 pixels wide, on a phone or in a narrow column of your theme, the cards move under the map in a row the visitor swipes through. The card swiped to is the one shown on the map, and there is no popup.

Search and Near me

The search field reads “Search by name, town or address”. It narrows the list and the pins as the visitor types. It looks in the desk’s name, its code, its city and its address, ignores accents and capitals, and each word typed must match. The count above the list follows, such as “1 rental desk”, and with no match the list says “No rental desks match your search.”

Near me asks the browser for the visitor’s position. While it waits the button reads “Finding you…”. Once the visitor allows it, each card shows its distance, such as “2.3 km away”, the list is sorted nearest first, a dot marks the visitor on the map, and the map shows them with their three nearest desks. The position stays in the visitor’s browser: it is not sent to your site or to Google by the plugin. If the visitor refuses, the button goes back to normal and its tooltip says “Your location is not available.” Browsers only offer this on a site served over HTTPS, and the button is hidden in a browser that cannot locate.

Book here

Book here links to the page with the booking form, with ?pcr_location= and the desk’s ID added, so the form opens with that desk chosen. See Shortcodes and blocks.

The plugin finds that page by itself: the first published page, by ID, that holds the Car rental booking block or the [plugixa_car_rental_booking] shortcode. It remembers the answer for a day, and looks again whenever a page is saved. When no page is found, the cards have no Book here button. Give the shortcode a page attribute to choose the page yourself, for example when the form is in a post, a widget or a template rather than in a page.

The map in the booking form

The Dates step of the booking form with Cascais Marina in the Location field, and under the search bar a map of the three desks beside a list where the Cascais Marina card is outlined and its button reads Chosen, while the card above it reads Choose

With Show a map to choose the pickup desk in the booking form on, the first step of every booking form shows the pickup desks under the search bar, on a map with a list beside it. It appears only when two or more published locations that take pickups have coordinates. With one desk there is nothing to choose.

It works like the locator, with these differences:

  • Only desks that take pickups are shown.
  • Each card has a Choose button instead of Book here. Clicking a card or a pin chooses that desk in the form’s Location field, and its button reads Chosen. There is no popup.
  • The Location field stays, and the two are always the same choice. Choosing in the field moves the map to that desk. The desk the form opens on, the first one or the one a link or a starting location chose, is shown chosen from the start.
  • Clicking beside a pin does not undo the choice, and on a phone swiping through the cards only browses. Only a tap changes the desk.
  • The map uses the Map style and the Pin colour, always has its list, search and Near me, and is shorter than the locator.

The return location is still chosen in the form’s own field. Availability, prices and the rest of the form work exactly as without the map. If Google’s script is blocked or fails to load, the form shows its Location field alone and works as before. See The booking form.

When nothing appears

The shortcode prints nothing visible in three cases. Each leaves a comment in the page source that says why.

Case Comment in the page source
Show maps on the site is off plugixa-car-rental map: maps are turned off in Settings
No API key is saved plugixa-car-rental map: set a Google Maps API key in Settings
No published location that takes pickups or returns has coordinates plugixa-car-rental map: no location has coordinates

A visitor sees no message and no empty box. The rest of the page is unaffected. The booking form’s map is left out in the same cases, and when fewer than two pickup desks have coordinates, without a comment.

If the key is saved but Google refuses it, for example because the Maps JavaScript API is not enabled, billing is not set up, or the key’s website restriction does not include your site, the list is drawn and Google shows its own error in the map area. See Troubleshooting.

What is loaded, and when

Google’s script is loaded only on a page that draws a map: a page where the shortcode draws one, or a page with a booking form that shows the map. Every other page loads nothing from Google. However many maps a page holds, each file is loaded once.

Loaded From When
The Google Maps JavaScript API, and the map images https://maps.googleapis.com and Google’s map servers In the visitor’s browser, on a page with a map
The plugin’s map script and stylesheet, and your booking form colours Your own site On the same page

The visitor’s browser contacts Google directly, sending your API key and what a browser normally sends, such as the IP address, the page’s address and the part of the map being looked at. Your server sends nothing to Google. The desks’ details (name, code, address, phone, coordinates, opening hours, the next eight days of closures, timezone and lowest daily price) are written into the page.

If your site caches pages, the prices and closures on a cached map are those of when the page was cached. The open or closed line is always worked out fresh in the visitor’s browser.

Because the map contacts a third party from the visitor’s browser, mention Google Maps in your privacy policy, and check whether your consent tool must hold it back until the visitor agrees. See Privacy and uninstall.

Without Pro

In the free edition [plugixa_car_rental_map] is not a registered shortcode, so WordPress prints the tag as plain text. Remove it from your pages if you go back to free. The booking form shows its Location field without the map.

Links ending in ?pcr_location= keep working in free: they belong to the booking form, not to the map, so links you placed in menus or emails still open the form at that desk.

The saved key and map settings are kept and are used again when Pro is reinstalled. See Free vs Pro.

Quick Links