By pan0s on
Hello guys,
Im wondering if there is a way to track and display in a map the location of users who bought a product in our store.
Are there any modules which offer this functionality.
Your insights will be highly appreciated - of course :).
Thanks
PS: The store implementation will be done using either Ubercart or Drupal commerce.
Comments
No ideas ? :(
No ideas ? :(
Drupal Commerce Uses the
Drupal Commerce Uses the Adddressfield module and you use Geocoder API and Geofield to geocode this info and then place it on a map using OpenLayers.
I wrote this tutorial for nodes, but it theory it could be translated to be used on users (it also allows for proximity searches through the UI):
*Download and enable Module Dependencies:
OpenLayers 7.x-2.0-alpha2
OpenLayers Proximity 7.x-2.x-dev
Chaos tools 7.x-1.0-rc1
Views 7.x-3.0-rc1
Address Field 7.x-1.0-beta2
Geocoder API 7.x-1.x-dev
Geofield 7.x-1.0-alpha5
Libraries 7.x-1.0
*Enable sub-modules:
Geofield Map 7.x-1.0-alpha5
Views UI 7.x-3.0-rc1
OpenLayers UI 7.x-2.0-alpha2
OpenLayers Views 7.x-2.0-alpha2
*Download library dependencies:
GeoPHP library
Place it in sites/all/libraries/geoPHP
*Go to admin/structure/types/add and create new content type called "Location"
*Go to admin/structure/types/manage/location/fields and add the following fields:
Label: Address > Field name: address > Field type: Postal address > Widget: Dynamic address form
Select which available countries you would prefer from the list. Leave blank to allow all of them.
Check off "Address form (country-specific)"
Note: The countries and their associated fields are handled by the Addressfield module. If you do not see your country or if it does not have the appropriate fields you need to file an issue with that module http://drupal.org/project/addressfield (Check to see if there is an issue in the queue about your missing country first before posting)
Label: Geofield > Field name: geofield > Field type: Geofield > Widget: Geocode from another field
*Go to admin/structure/types/manage/ol_locator_location/display and change the Default display for Geofield:
Label: Hidden > Format: OpenLayers
Click on gear icon and select the following:
OpenLayers Preset: Geofield Formater Map > Data options: Use full geometry
*Go to admin/structure/openlayers/layers/settings and set the following:
Google Maps API version: v3.2
*Note: At the time of writing this v3.2 does not require an API Key, however even after swithcing it to v3.2 there were notifictions to still obtain an API Key.
Go to http://code.google.com/apis/maps/signup.html and obtain a Google API Key:
Check off "I have read and agree with the terms and conditions" > Enter your website's URL > Generate API Key
Copy the API Key and paste it back in your site:
Example: ABQIAAAAFBb6W7U6kspYDTkcjbgMVRQaoR5xxFjMWfVTyaFsNOLG6PH6ARQdE32MUAXQFeDcdOPs3R4yZGxeFg
Lets test to see if the Geocoding is working by creating a Test Location
When creating a test content type, make sure you are using a well established address. If Google doesn't know about your address, then neither will your new site.
* Go to admin/structure/views/add and create a new view with the following information
View name: Proximity Search > Description: Displays geocoded locations on a dynamic map for users to do proximity searches. > Show: Content of type: Location sorted by: Unsorted > Continue & edit
*Add the following fields and keep their default values, except were noted*:
Content: Title > *Check off Create a label: "Title"
Content: Address (Address)
Content: Geofield (Geofield) > *Exclude from display
Proximity: Distance (Distance)
*Add the following Filter Criteria to the existing Content: Published (Yes) and Content: Type (= Location)
Proximity: Great-circle (exposed) > Expose this filter to visitors, to allow them to change it > Label: Proximity > add "10" to Value field > Unlock unit of measurement > Unlock location
Global: Text area: Display even if view has no result
"Find a location near you. You can search using your city, province/state or a postal/zip code."
No results behavior > Global: Text area and add the following:
Sorry, no results found.
1. Verify the accuracy of your postal/zip code
2. Check the spelling of your city, province or state
3. Increase the proximity distance
Submit button text: Search
Add new display: OpenLayers Data Overlay
Format:
Settings > Apply this openlayers (override) > Map Data Sources: WKT > WKT Field: Geofield > Description Field > > Apply (this display)
**Save the view
**Go to admin/structure/openlayers/maps
**Clone the default map
General information > Name: location_map . Title: Location Map > Map Description: This is the default location map.
Layer & styles > Overlay layers (select the view we just created) Locations "Enabled" "Activated" Do the same for Placeholder for Geofield Formatter
Behaviours > Pop Up (have to come back and "Select layer to apply popups to." later) > Zoom to Layer "Select layer to zoom to when the map is loaded" > Point Zoom Level : 20 ********
**Save the map
**Go back to the view we just created admin/structure/views/view/proximity_search/edit
Add display 'Page"
Path: /locator
Format: OpenLayers Map > Apply (this display) > Map: Locations Map (The one we just created in OpenLayers) > Apply
**Save the view (We should now see our map in the preview pane at the bottom of our view, with any test content
**Add display:attachment
Format: Table > Apply (this display)
Attach to: Page
Inherit exposed filters: Yes
Remove the Header > Global: Text area > Apply (this display)
Items to display: Display a specified number of items | 5 items
Inherit pager: Yes
Render pager: Yes
**Save View
Behaviours > Pop Up > Layers > proximity_search_openlayers_1 (The views Openlayers map we just created)
Zoom to Layer > Zooms to the extent of a given layer on map loading. > proximity_search_openlayers_1
Return back to admin/structure/types/manage/location/display > click gear icon and change OPen Layers Preset to the Location Map that we just created > Update > Save
An example site to show, please?
An example site to show, please? Would be great to see it on a site where it's used. And isn't tutorial online?
I do not have a site with it
I do not have a site with it in use yet. However, if you want to test it out, use my sandbox project to get up and running quickly. http://drupal.org/sandbox/nicoz/1303200
Nicoz,first of all i would
Nicoz,
first of all i would like to thank you for your super comprehensive answer...thumbs up!
i suppose i can use "this" in combination with ubercart, right ? i will just have to install address field...
In theory, you can use it
In theory, you can use it with Ubercart. Although in my tutorial, it suggests addressfiled, I think geocoder can geocode pretty much anything you throw at it (maybe including the address fields in Ubercart). I haven't tried, but I don't see any reason why it wouldn't work.