2

Is it possible to use form api (write codes) to display and store google map Latitude and Longitude? Most of the modules available is to add new google map field to drupal content type. I don't want to use drupal content type to store as a node. i wish to store the location using db_insert. Thanks

4
  • Short Answer would be "yes" I guess. Depending on your skills you can do pretty much whatever you want using Form API.
    – berliner
    Mar 29, 2015 at 19:34
  • Thanks for the feedback. I'm having no clue on how to do it since i couldnt find any form api type for maps or other module i can use. Are you able to share some idea on how to do it? Thanks
    – jared jh
    Mar 30, 2015 at 2:31
  • You're question is rather broad. I would advise you to add more information about what you want to achieve, what you have already tried, and in what way that has failed. Please refer to the Help Center for details on how to ask questions that will more probably receive good answers.
    – berliner
    Mar 30, 2015 at 6:43
  • Regarding a Form API type for maps: I know of nothing like that either. If you want to achieve something like that using Form API you would have to write it yourself I guess.
    – berliner
    Mar 30, 2015 at 6:45

1 Answer 1

1

Yes, there are couple of ways of doing this. You would need to install Geofield which has a Form API element that can be used as such:

$form['location'] = array(
  '#type' => 'geofield_latlon',
  '#title' => t('Location'),
);

That'll give you a start to work from. I'm looking at embedding a clickable Google map using the GMap module as follows:

$form['contact_us']['map'] = array(
  '#description' => t('Enter your location to be displayed as a Google map.'),
  '#type' => 'gmap',
  '#title' => t('Location'),
  '#settings' => array(
    'zoom' => 8,
    'id' => 'location_map',
  ),
);

It shows the map however that is about all, so far. But it's another starting point for you!

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.