Contents
Overview
This Extra Field Type is available in WordPress Creation Kit Hobbyist or Pro. The Map Field allows to add a Map in a Post, Page or Custom Post Type. Inside the Map you can Pin a location.
Creating a Map Field
To add a Map Field to a previously created Custom Meta Box, under the Meta Box Fields tab simply insert a Field Title and under Field Type make sure you select Map.
The Map Field contains options to customize it:
- Description – Allows you to specify a description for the Map Field
- Required – Select whether the field is required or not
- Default Latitude – The latitude at which the Map Field should be displayed when no pins are attached
- Default Longitude – The longitude at which the Map Field should be displayed when no pins are attached
- Default Zoom – Add a number from 0 to 19. The higher the number the higher the zoom
- Map Height – The height of the map
Page, Post or Custom Post Type Edit Screen
This is how the Map Field we created above looks like in the Edit Screen:
Google Maps API
In order to make the Map Field work you will need to add your Google Maps API in WCK -> Start and Settings -> Extra Settings -> Google Maps API -> Save.
How to create your Google Maps API Key
First you will need to login into your Google account and then access Google Developers Console. Here you will be able to Register your application for Google Maps JavaScript API.
We will select to Create a new project and click on Continue.
Now the API is enabled for our project. We have to create credentials so we will click on “Go to credentials”.
We will select Google Maps JavaScript API that will be called from a Web browser (Javascript). We need to click on “What credentials do I need?” to continue.
We can give our API Key a Name like Google Map API Key. Also, we can add multiple HTTP referrers so that we can limit map loading only for these URLs. If you wish to allow an entire domain to load the Google Maps you can add an asterix at the end of the URL.
http://www.yourdomain.com/*
If we don’t add a HTTP referrer, requests will be accepted from any referrer (domain). To continue we have to click on “Create API key”
Our API Key is now Created. Copy and Paste it in Profile Builder -> Manage Fields -> Map Field -> Google Maps API Key. To finish the process and go to API Manager click on “Done”.
Enable Google Maps JavaScript API
To enable Google Maps JavaScript API we have to go to Google APIs -> API Manager -> Overview -> And click on Google Maps JavaScript API.