Jump to Content

Objective HTML

Google Maps Proxy

Turn any ExpressionEngine site into a Google Maps proxy

Overview

Google Maps Proxy allows you to quicky and easily enable your own proxy to re-route requests away from a cloud or shared hosting environment. Every request is automatically cached to avoid duplicate requests to Google, along with automatically routing to the correct API endpoints. This add-on extends the Google Maps for ExpressionEngine API to become the first official expansion pack.

Requirements

Google Maps Proxy is an official expansion pack to Google Maps for ExpressionEngine, which extends the Google Maps for ExpressionEngine API, and therefore a valid license for each is required. Google Maps Proxy will not work if Google Maps for ExpressionEngine is not installed.

Installation

Uploading the files
Copy the gmap_proxy module directory to your /system/expressionengine/third_party/ directory.
Installing the add-on
Go to the Modules page and click install
Choose Install on the Module

Once Google Maps Proxy has been installed, you should create a new template group and a template for your API controller. An API controller allows you to execute HTTP requests to the API with a nicely formatted URL in ExpressionEngine (instead of using an ACT id).

Recommended Pattern

API's need to remain solid and stable for the forseeable future, so it's important to pick a URL schema that will stand the test of time. Following recent trends of many of the popular REST API's, it's recommended to use the following syntax. It's important to note, you can use whatever you want and nothing techinically preventing you from doing so, this is just my opinion.

/api/v1/geocode
/api/v1/directions

So, you would create an "api" template group and a file called "v1.html". That file will contain the template tag to perform the routing.


{exp:gmap_proxy:route method="{segment_3}"}
Last Step

Don't forget to open the config file in your installed Google Maps for ExpressionEngine add-on. Find the section with the proxy information, and follow the instructions. Use the URL you just created in the config file to finilize the setup. You now have a fully installed proxy that will handle all your deferred Google Maps requests.