/
marker.php
136 lines (122 loc) · 2.97 KB
/
marker.php
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/**
* Marker Class
*/
class WPGeo_Marker {
// Reference
var $id = null;
var $name = null;
var $description = null;
// Marker Properties
var $width = 20;
var $height = 34;
var $anchorX = 10;
var $anchorY = 34;
var $image = null;
var $shadow = null;
/**
* Constructor
*/
function __construct( $id, $name, $description, $width, $height, $anchorX, $anchorY, $image, $shadow = null ) {
$this->set_id( $id );
$this->set_name( $name );
$this->set_description( $description );
$this->set_size( $width, $height );
$this->set_anchor( $anchorX, $anchorY );
$this->set_image( $image );
$this->set_shadow( $shadow );
}
/**
* Set the marker's ID.
*
* @param string $id ID.
*/
function set_id( $id ) {
$this->id = $id;
}
/**
* Set the marker's name.
*
* @param string $name Marker name.
*/
function set_name( $name ) {
$this->name = $name;
}
/**
* Set the marker's description.
*
* @param string $description Description.
*/
function set_description( $description ) {
$this->description = $description;
}
/**
* Set Size
* Sets the marker's width and height dimensions.
*
* @param int $width Width.
* @param int $height Height.
*/
function set_size( $width, $height ) {
$this->width = $width;
$this->height = $height;
}
/**
* Set Anchor
* Sets the marker's anchor coordinates.
*
* @param int $x
* @param int $y
*/
function set_anchor( $x, $y ) {
$this->anchorX = $x;
$this->anchorY = $y;
}
/**
* Set the marker's image file.
*
* @param string $image Image URL.
*/
function set_image( $image ) {
$this->image = $image;
}
/**
* Set Shadow
* Sets the marker's shadow image file.
*
* @param string $shadow Shadow image URL.
*/
function set_shadow( $shadow ) {
$this->shadow = $shadow;
}
/**
* Get the JavaScript that defines a marker.
*
* @return string JavaScript.
*/
function get_javascript() {
global $wpgeo;
$icon = apply_filters( $wpgeo->get_api_string( 'wpgeo_api_%s_markericon' ), '', $this );
if ( ! empty( $icon ) ) {
return "var wpgeo_icon_" . $this->id . " = " . $icon . ";";
}
return $icon;
}
/**
* Get Admin Display
* Gets the HTML to display the marker in the admin.
*
* @return string HTML.
*/
function get_admin_display() {
return '<tr valign="top">
<th scope="row">' . esc_html( $this->name ) . '</th>
<td>
<p style="margin:0px; background-image:url(' . esc_url( $this->shadow ) . '); background-repeat:no-repeat;"><img src="' . esc_url( $this->image ) . '"></p>
<p style="margin:10px 0 0 0;">' . $this->description . '<br />
{ width:' . esc_html( $this->width ) . ', height:' . esc_html( $this->height ) . ', anchorX:' . esc_html( $this->anchorX ) . ', anchorY:' . esc_html( $this->anchorY ) . ' }
</p>
</td>
</tr>';
}
}