I have multiple content types - restaurants, hotels, events for example, and each of them has a location field.
I want to show all restaurants on one map, all hotels on anther etc, and also all content types on one map. I've achieved this using separate location fields on each content type - field_hotel_location, field_event_location, etc - Openlayers and Views.
I'm wondering whether I would have been better off creating one generic location field - field_location - and using that on each of the content types, and then using Views to limit which content type is displayed on the map overlays.
Does anyone have an opinion on this - would there be benefits? I don't have any data at the moment, so it would be each to change the fields.
Any help gratefully received, thanks.
Comments
Yes, I would suggest using
Yes, I would suggest using one location field base. This way you can have both node types on one map, and filter/sort by the same location field. For example, if you were to use geofield and then geocoder to get coordinates for each hotel and restaurant, you can use search_api_location to present an exposed Views filter to the user. They can then limit results to, say, 50 miles from their entered location. Or you can override the 50 miles with a really high number and hide it, and then add a Sort to show the closest locations first. Either way, doing this with multiple location field bases on the same map, with the same filter becomes tricky to say the least.
Edit: I think geofield/geocoder also include a views filter/sort if you don't want to use search_api_location (search_api would let you use Apache Solr as a backend).
Actually, thinking about it
Actually, thinking about it more, using different address field bases (either location or addressfield modules) doesn't prevent you from using geocoder to add coordinate details to a single geofield base field.
The point still stands about exposed filters in views though. Storing the data as different field bases makes things tricky if you need to combine multiple node types.
One generic location field is best
Agree with jessehs: one location field used across multiple content types is best.
Which module are you using to store your location (latitude/longitude)? There's at least 5 popular ones: Geofield, Location, GetLocations, Geolocation Field, your own simple text fields.
Then which map provider do you want to use? There's at least 3: Google, OpenLayers, Leaflet. Note that depending on the module you pick above you may be locked into one of map providers. Unless you use IP Geolocation Views and Maps.
Then which widgets and map gimmicks are you after? E.g. do you wish to the show visitor marker among your other markers? Center the map on it? Apply location marker color differentiation based on price range etc.?
Here are some references (with links to presentations etc.):
http://drupal.org/node/1704948
http://drupal.org/project/ip_geoloc (my favorite, of course)
Thanks to all, you've
Thanks to all, you've convinced me, I'll use just one location field. I'm using Geofield to store the data and OpenLayers to present.
I've used different OpenLayers layers via Views to create the map overlays. I've included all overlays on the map that shows all content, which I like as 1) it allows me different icons per content type (I've also seen somewhere that I could use different icons based on taxonomy which I may explore in the future) and 2) it allows the user to show/hide layers.
The only functionality that I'm lacking at the moment is the ability to calculate (and store) the length of a plotted walk (line string).
Thanks again and thanks for the links.
Long life to ip_geoloc module
Hi, just to say I totally agree with RdeBoer ... also because, having already tested many geo Drupal Modules (all the mentioned by him) I became a great fan of its ip_geoloc http://drupal.org/project/ip_geoloc.
Here is a nice implementation of it, with multiple maps that share the same location fields among different content types.
http://www.italomairo.com/geoblogcms/en/ip-locations-leaflet
;-)
Digital Communication, Web 2.0 & Web Gis 2.0 Opensource
www.italomairo.com
email: itamair@me.com