Online Book Reader

Home Category

Mapping With Drupal - Alan Palazzolo [20]

By Root 311 0
does not have an office address, and instead has a PO Box like, “PO Box 23505, Brooklyn, NY 11202.” This address, when geocoded by Google, shows up in downtown Brooklyn. To see this, click the “Save” button.

NOTE

If you want to create lots of content for testing a new site, the Devel Generate module will do this for you. When doing this, the GMap module will insert random countries and coordinates for this content.

Edit the company that you just saved. On the small map, zoom in until you can see the streets. The business owner of this company wants to be associated with downtown Manhattan, so click the map in that location and notice how the latitude and longitude fields change. (There are two pairs of latitude and longitude: one showing the current coordinates for the node under the heading “Current Coordinates”; and the other pair, further down the form, appearing as two text fields. The latter are the ones that change when you click a new location on the map.) Click the “Save” button again. The business still has the same address, but if you edit the business again, you will see that the location on the map is now lower Manhattan, where you clicked, and the “Source” for the current coordinates is now “User-submitted” instead of “Geocoded (Exact).”

NOTE

This is a useful feature when mapping things that cannot be easily geocoded, such as a park, or when you are mapping things at a very detailed scale and want to pinpoint the entrance to a conference hall rather than the middle of the building.

As you edit the business and look at the map, you have found it unhelpful because it is a small map showing most of the world. To change this, go to the Location module’s configuration page again at admin/config/content/location/main. Toward the bottom of this page is a field titled “Location chooser macro,” which contains [gmap]. This is the GMap module’s way of setting up behaviors and display options for a map. The current setting uses the default values set on the GMap module’s configuration page, admin/config/services/gmap. The easiest way to create a new macro is to use the module provided for this purpose.

Go to the module page at admin/modules and enable the GMap Macro Builder module. Enable permissions for the roles that will need to configure map defaults at admin/people/permissions#module-gmap_macro_builder—usually just the “Administrator role.”

Go to the “Build a GMap macro” page at map/macro. The map at the top of this page is the one that will be set by the macro that you are creating. The first section is the “Overlay editor.” When someone is editing a location, the Overlay editor determines stuff like the colors of the map pins and lines. The defaults are fine for now.

The next section of the form contains the more important settings. If you are creating a website that has a particular geographic focus, you probably want a map that defaults to a location in that area, rather than one that shows the whole world. Enter a location that represents this focus in the “Address” field (for example, New York, NY). When you click or tab out of this field, the location will be geocoded and the latitude and longitude will be updated below, in the field labeled “The Latitude and Longitude of the centre of the map.”

If you scroll back to the top of the page, you will now see a small map centered on the location you entered. The map is still very zoomed out, so change this in the field labeled “The current magnification of the map.” This defaults to 3, so increase it and look at the updated map at the top of the page to see if the new value works.

We now have the map showing a more useful location, but it is still very small. To change the size of the map, we need to update the “Map width” and “Map height” fields. For a map that is being used to set a location, we want to use the full space available on the page, so change the width to 95%. Percentage heights are not well supported across browsers, so change the height to 300px.

As you have gone through these steps, you may have noticed that the last field

Return Main Page Previous Page Next Page

®Online Book Reader