Thứ Hai, 15 tháng 7, 2013

Using Simple Google Maps Module In Drupal 7

The Simple Google Maps module for Drupal is a field formatter which displays a map using Google Maps. Using this module, you can display a map without having to install three or more location modules. All you have to do is, create a text field to store the address and configure the Simple Google Maps field formatter in the manage display section.

The geocoding - converting the address to a longitude and latitude coordinate - of the address is handled by Google Maps API when the formatter is rendered. Drupal will not store the geographical coordinates for each address. If you need to store coordinates in the database look at the Geofield module.
In this tutorial, I'll show you how to store an address and display a map in a few easy steps.

Getting Started

First, go download and install the Simple Google Maps module.

Create Address Text Field

The first piece of work we'll have to do is create a text field.

How To

1. Go to Structure -> "Content types" (admin/structure/types) and click on the "manage fields" link for the Article content type.
2. Create a new field called Address, select Text from the "Field type" and select "Text field" as the widget. Click on the Save button to create the field.

Fig 1.0
3. Go to the manage display section (admin/structure/types/manage/article/display) for the Article content type. Select the "Google Map from one-line address" formatter from the Address drop-down.

Fig 1.1
4. Click on the cog wheel to configure the map. Using the configuration form, you can change the width/height, zoom level and map type. All we'll do is change the "Width of embedded map" and "Height of embedded map" to 600.

Fig 1.2

Click on the Update button and save the "Manage display" form.
5. Now go and test the map out, go to Content -> "Add content" -> Articles (node/add/article) and add an address to the field we created for storing addresses.
Fig 1.3
Once you have saved the content, you should see a map with a marker on the entered location.
Fig 1.4

As you can see Simple Google Maps module gets straight to the point. This module can be used for most location use cases on a website.

Không có nhận xét nào:

Đăng nhận xét

Học lập trình web căn bản với PHP

Bài 1: Các kiến thức căn bản Part 1:  https://jimmyvan88.blogspot.com/2012/05/can-ban-lap-trinh-web-voi-php-bai-1-cac.html Part 2:  https://...