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