I`m trying to use the geofield module, and load it with google maps widget in one my custom forms.

Yet i can't find any way to use the form api to display this field.

$form['geofield'] = array(
'#title' => 'geofield',
'#type' => 'geofield',

Any suggestion is welcome, i don't mind reading some docs.

1 Answer 1


Geofield module is rather complex module which adds a lat/long fieldset and so many other stuff such as adding new fields, validation, etc.

Anyway, you can create a latitude and longitude input field using the #type => 'geofield_latlon'.

$form['geofield'] = array(
  '#title' => 'geofield',
  '#type' => 'geofield_latlon',

Note that this will return a generic longitude latitude form. NOT a Google Maps choose-location field. See geofield.elements.inc for more information on how this element is validated and themed.

Update: I forgot to mention that the above element is available in the 7.x-2.x branch.

  • Geofield_latlon doesn't seem to show anything either, its like nothing happends, what ever the type i`m trying to use.
    – Arjan
    Commented Sep 3, 2013 at 9:48
  • My bad... I've installed 7.1 geofield module instead of the 7.2 branch. Now i'd have the latlon field.
    – Arjan
    Commented Sep 3, 2013 at 10:07
  • Sorry I forgot to mention the branch. 2.x branch has proximity filters as well, so I'm using that version in all my sites. Did geofield_latlon work ?
    – AKS
    Commented Sep 3, 2013 at 10:59
  • Yeah it seems to work now. Next step would be the map. I figured out i needed to install geofield gmap module to be able to have the widget for it. Any idea, how i would call that widget?
    – Arjan
    Commented Sep 3, 2013 at 11:40
  • the only type i can find in the geofield_gmap files is geofield_gmap
    – Arjan
    Commented Sep 3, 2013 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.