GMap and Location modules w Drupal

To help overcome confusion w using GMap and Location modules.

From a post I made to Drupal site, to thread w some people confused re using GMap and Location modules, which are a great help with adding Google Maps to a Drupal site, but seem sparsely documented.

Only basic info here, but might help you get started. I'm using both GMap and Location modules, plus Views; only very simple usage of them, but some things working.

Basic Setup for Gmap and Location modules

Under Site Configuration, visited GMap – where main thing seems to be adding Google Maps API key for website, and saving. [Can make other changes, for default map that will appear when use GMap macro]

For GMap Location, I enabled Google Map API geocoding; maybe not helpful for me yet. Plus set a few other things, but not vital to do so. Useful to set the default maps, to suit your likely user base and, perhaps, likely range of articles on site.

For Location, I enabled the display of locations – would seem, then, this is important step. Chose option to use google map to set latitude and longitude: really useful thing to do. Map Links and Geocoding not vital for getting basic functionality, I've discovered.

Enable Locations for Content Types

Content types will need editing I believe (after seeing post below). For each content type, can decide if wish to enable Location, and can choose various settings for this.

Once this is done, can edit articles (nodes), adding Location info. I believe these nodes should then show on the auto-generated map showing locations of nodes; but surely more useful to include in Views.

Markers for Taxonomy Terms

Gmap Location enables you to set markers that will appear for certain content types (and user categories). But if you want to have different markers for different taxonomy terms: head to administer – taxonomy, and edit each vocabulary for which you want to have terms w different markers, checkiing option to enable markers for terms. Then, you can edit each term in this vocabulary, selecting marker types.

Users and Location

Then, User management – user settings, and at the bottom [for me] there's chance to choose re Location settings for each user. Maybe here crucial to change maximum number of locations from 0 – it's not like some options in Drupal where "0" rather oddly stands for unlimited. Perhaps just 1 would be ok, unless for quirky users who are typically in several places. Might also choose 1 for minimum, if want to require users to add location.
Here, too, there are further options, but maybe more a matter of taste than crucial for getting location working.

In doing the above, I found items automatically added to navigation menu – linking to Node locations, User locations; and to GMap macro builder.

Gmap and Views

Views is a great help for creating custom maps showing locations of nodes, and info on them. I was confused by seeing the default location_table and location_directory views (added when install Location I believe): these produce lists, rather than maps.

To create a gmap w Views, create a new view: node type works, I've found. Key thing here is to choose style – gmap; looks like after you've done so, you must also paste some Gmap info so that you can generate the base map Views will add markers to. Under filter, choose to have Location id is not NULL (ie to choose nodes with some Location info). After this, there are various settings you can play around with; inc ability to choose which info will appear when someone clicks on a map marker: you might, say, have a node title that links to node, plus teaser.

[amazon 0596515804 full]

[amazon 0470556110 full]


    • getting locative info to appear on node edit form
      You must set the number of locations on the content type. Set min = 1, max =1 and number added at once to 1 (or substitute your number).

  1. enable location for content types

    Maybe you have to first enable location for whichever content types you wish to enable it for.

    Via administer – content management – content types, you can edit each of the content types for which you wish to use Location. Various choices here; perhaps experiment a bit to see which suits you.

    Should then start working for you; as you add or edit article (node) of content type for which you’ve enabled Location, you can add info.

    With Views, can then choose which of the content types to display in a given View.

    Hope this helps!

    • Using gmap

      I’m using location and gmap on a number of sites, I don’t see any reason why the content type needs to be created after location has been enabled. Just make sure that when you edit the content type you allow location to work – i.e. setting a number of required locations. If you have any questions about drupal development get in touch with my company Inet Digital [name edited in] through that link [edited out – Martin] and we’re happy to help out. Cheers,

      • gmap and content types

        err, I didn’t say that have to create content type after enabling location

        so, what’s your point, beyond attempting quick link spamming?

  2. Did you resolve this?
    I’m having a similar sounding problem. I can set location parameters per content by managing content types for all the types defined on my site.

    But when I then go to create content the location box only appears for content types created after location was installed.

    Would really appreciate help with this one.

  3. re location n content types

    I have it working for pre-existing content types.

    You’ve tried settings, inc that can set at least 1 location for the content type? Otherwise, I don’t know.

  4. Go to administer >location
    Go to administer >location and click “enable the display of locations.

    Save, then look at the top of the options on that page and click “geocoding options”. From there, scroll down to the countries you want to include and click the google maps options.

    The location option in your cck types should be available when you edit them now.

Leave a Reply