@@ -169,8 +169,21 @@ protected function markers_geojson($incidents, $category_id, $color, $icon, $inc
169
169
{
170
170
// Handle both reports::fetch_incidents() response and actual ORM objects
171
171
$ marker ->id = isset ($ marker ->incident_id ) ? $ marker ->incident_id : $ marker ->id ;
172
- $ latitude = isset ($ marker ->latitude ) ? $ marker ->latitude : $ marker ->location ->latitude ;
173
- $ longitude = isset ($ marker ->longitude ) ? $ marker ->longitude : $ marker ->location ->longitude ;
172
+ if (isset ($ marker ->latitude ) AND isset ($ marker ->longitude ))
173
+ {
174
+ $ latitude = $ marker ->latitude ;
175
+ $ longitude = $ marker ->longitude ;
176
+ }
177
+ elseif (isset ($ marker ->location ) AND isset ($ marker ->location ->latitude ) AND isset ($ marker ->location ->longitude ))
178
+ {
179
+ $ latitude = $ marker ->location ->latitude ;
180
+ $ longitude = $ marker ->location ->longitude ;
181
+ }
182
+ else
183
+ {
184
+ // No location - skip this report
185
+ continue ;
186
+ }
174
187
175
188
// Get thumbnail
176
189
$ thumb = "" ;
@@ -296,16 +309,44 @@ protected function clusters_geojson($incidents, $category_id, $color, $icon)
296
309
{
297
310
$ marker = array_pop ($ markers );
298
311
$ cluster = array ();
312
+
313
+ // Handle both reports::fetch_incidents() response and actual ORM objects
314
+ $ marker ->id = isset ($ marker ->incident_id ) ? $ marker ->incident_id : $ marker ->id ;
315
+ if (isset ($ marker ->latitude ) AND isset ($ marker ->longitude ))
316
+ {
317
+ $ marker_latitude = $ marker ->latitude ;
318
+ $ marker_longitude = $ marker ->longitude ;
319
+ }
320
+ elseif (isset ($ marker ->location ) AND isset ($ marker ->location ->latitude ) AND isset ($ marker ->location ->longitude ))
321
+ {
322
+ $ marker_latitude = $ marker ->location ->latitude ;
323
+ $ marker_longitude = $ marker ->location ->longitude ;
324
+ }
325
+ else
326
+ {
327
+ // No location - skip this report
328
+ continue ;
329
+ }
299
330
300
331
// Compare marker against all remaining markers.
301
332
foreach ($ markers as $ key => $ target )
302
333
{
303
334
// Handle both reports::fetch_incidents() response and actual ORM objects
304
- $ marker ->id = isset ($ marker ->incident_id ) ? $ marker ->incident_id : $ marker ->id ;
305
- $ marker_latitude = isset ($ marker ->latitude ) ? $ marker ->latitude : $ marker ->location ->latitude ;
306
- $ marker_longitude = isset ($ marker ->longitude ) ? $ marker ->longitude : $ marker ->location ->longitude ;
307
- $ target_latitude = isset ($ target ->latitude ) ? $ target ->latitude : $ target ->location ->latitude ;
308
- $ target_longitude = isset ($ target ->longitude ) ? $ target ->longitude : $ target ->location ->longitude ;
335
+ if (isset ($ target ->latitude ) AND isset ($ target ->longitude ))
336
+ {
337
+ $ target_latitude = $ target ->latitude ;
338
+ $ target_longitude = $ target ->longitude ;
339
+ }
340
+ elseif (isset ($ target ->location ) AND isset ($ target ->location ->latitude ) AND isset ($ target ->location ->longitude ))
341
+ {
342
+ $ target_latitude = $ target ->location ->latitude ;
343
+ $ target_longitude = $ target ->location ->longitude ;
344
+ }
345
+ else
346
+ {
347
+ // No location - skip this report
348
+ continue ;
349
+ }
309
350
310
351
// This function returns the distance between two markers, at a defined zoom level.
311
352
// $pixels = $this->_pixelDistance($marker['latitude'], $marker['longitude'],
0 commit comments