I want to create a database-driven website with Drupal 6 to gather some information from users that is related to the location; I want to create a form (and I don't want to use Webforms, or CCK) to get some data from users, and to get coordinates by creating a point on a map (by Openlayers or Gmap API), and then saving those data in a database table. I also want to integrate it with Views module so i can make a query from data.
3 Answers
I'm quite happy with the Geolocation Field module for Drupal 7. It allows you to put a field on any entity (user or node or whatever) that uses a map. It also has an html5 module to collect the information. Great stuff, actively maintained.
There is already a module that is doing the form part, see HTML5 user geolocation.
Here is a quote about it (from the module's project page):
... a simple module to let users store their location on the edit account page. It uses HTML5’s geolocation API and stores latitude and longitude. How you use that data is up to other modules.
It was used on Drupal.org when Drupal.org used Drupal 6.
For more than users or for a Drupal 7 version, try Geolocation Field with the Geolocation HTML5 widget. Now that it is on Drupal 7, Drupal.org uses the Geolocation Field for this feature.
-
thank you for your reply but I want to know how to use map in my custom form– RaoofApr 16, 2011 at 17:51
-
1
function geo_get_coords($address) {
$map_key = "put your google map key";
$url = sprintf('http://maps.google.com/maps/geo?&q=%s&output=csv&key=%s',rawurlencode($address),$map_key);
if ($result = file_get_contents($url)) {
$result_parts = explode(',',$result);
if($result_parts[0] != 200) {
return FALSE;
}
$coords['lat'] = $result_parts[2];
$coords['lon'] = $result_parts[3];
}
return $coords;
}