geofield.microdata.inc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * implements hook_microdata_value_types_alter().
  4. */
  5. function geofield_microdata_value_types_alter(&$types) {
  6. $types['geofield'] = 'item_option';
  7. }
  8. /**
  9. * Implements hook_microdata_suggestions().
  10. */
  11. function geofield_microdata_suggestions() {
  12. $suggestions = array();
  13. // Standard suggestion for co-ordinates.
  14. // http://schema.org/GeoCoordinates
  15. //
  16. // Output example:
  17. // <div itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates">
  18. // Latitude: 40 deg 44 min 54.36 sec N
  19. // Longitude: 73 deg 59 min 8.5 dec W
  20. // <meta itemprop="latitude" content="40.75" />
  21. // <meta itemprop="longitude" content="73.98" />
  22. // </div>
  23. $suggestions['fields']['geofield']['schema.org/GeoCoordinates'] = array(
  24. '#itemprop' => array('geo'),
  25. '#is_item' => TRUE,
  26. '#itemtype' => array('http://schema.org/GeoCoordinates'),
  27. 'wkt' => array(
  28. '#itemprop' => array('latitude', 'longitude'),
  29. ),
  30. 'lat' => array(
  31. '#itemprop' => array('latitude'),
  32. ),
  33. 'lon' => array(
  34. '#itemprop' => array('longitude'),
  35. ),
  36. 'latlon' => array(
  37. '#itemprop' => array('latitude', 'longitude'),
  38. ),
  39. );
  40. // Suggestion for more complicated shapes.
  41. // http://schema.org/GeoShape
  42. //
  43. // Output example:
  44. // <div itemprop="geo" itemscope itemtype="http://schema.org/GeoShape">
  45. // WKT: LINESTRING (30 10, 10 30, 40 40)
  46. // <meta itemprop="line" content="30 10 10 30 40 40"/>
  47. // </div>
  48. $shape_base = array(
  49. '#itemprop' => array('geo'),
  50. '#is_item' => TRUE,
  51. '#itemtype' => array('http://schema.org/GeoShape'),
  52. );
  53. // Suggestion for a line.
  54. $suggestions['fields']['geofield']['schema.org/GeoShape line'] = $shape_base;
  55. $suggestions['fields']['geofield']['schema.org/GeoShape line']['schemaorg_shape']['#itemprop'] = array('line');
  56. // Suggestion for a polygon.
  57. $suggestions['fields']['geofield']['schema.org/GeoShape polygon'] = $shape_base;
  58. $suggestions['fields']['geofield']['schema.org/GeoShape polygon']['schemaorg_shape']['#itemprop'] = array('polygon');
  59. return $suggestions;
  60. }