diff --git a/overviewer_core/aux_files/genPOI.py b/overviewer_core/aux_files/genPOI.py index e25a053..f41e93e 100755 --- a/overviewer_core/aux_files/genPOI.py +++ b/overviewer_core/aux_files/genPOI.py @@ -216,6 +216,22 @@ def main(): d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, hovertext=result) elif type(result) == tuple: d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result[1], hovertext=result[0]) + # Dict support to allow more flexible things in the future as well as polylines on the map. + elif type(result) == dict: + d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result['text']) + # Use custom hovertext if provided... + if 'hovertext' in result and isinstance(result['hovertext'], basestring): + d['hovertext'] = result['hovertext'] + else: # ...otherwise default to display text. + d['hovertext'] = result['text'] + if 'polyline' in result and type(result['polyline']) == tuple: #if type(result.get('polyline', '')) == tuple: + d['polyline'] = [] + for point in result['polyline']: + # This poor man's validation code almost definately needs improving. + if type(point) == dict: + d['polyline'].append(dict(x=point['x'],y=point['y'],z=point['z'])) + if isinstance(result['color'], basestring): + d['strokeColor'] = result['color'] if "icon" in poi: d.update({"icon": poi['icon']}) if "createInfoWindow" in poi: @@ -228,6 +244,22 @@ def main(): d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, hovertext=result) elif type(result) == tuple: d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result[1], hovertext=result[0]) + # Dict support to allow more flexible things in the future as well as polylines on the map. + elif type(result) == dict: + d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result['text']) + # Use custom hovertext if provided... + if 'hovertext' in result and isinstance(result['hovertext'], basestring): + d['hovertext'] = result['hovertext'] + else: # ...otherwise default to display text. + d['hovertext'] = result['text'] + if 'polyline' in result and type(result['polyline']) == tuple: #if type(result.get('polyline', '')) == tuple: + d['polyline'] = [] + for point in result['polyline']: + # This poor man's validation code almost definately needs improving. + if type(point) == dict: + d['polyline'].append(dict(x=point['x'],y=point['y'],z=point['z'])) + if isinstance(result['color'], basestring): + d['strokeColor'] = result['color'] if "icon" in poi: d.update({"icon": poi['icon']}) if "createInfoWindow" in poi: @@ -240,6 +272,22 @@ def main(): d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result, hovertext=result) elif type(result) == tuple: d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result[1], hovertext=result[0]) + # Dict support to allow more flexible things in the future as well as polylines on the map. + elif type(result) == dict: + d = dict(x=poi['x'], y=poi['y'], z=poi['z'], text=result['text']) + # Use custom hovertext if provided... + if 'hovertext' in result and isinstance(result['hovertext'], basestring): + d['hovertext'] = result['hovertext'] + else: # ...otherwise default to display text. + d['hovertext'] = result['text'] + if 'polyline' in result and type(result['polyline']) == tuple: #if type(result.get('polyline', '')) == tuple: + d['polyline'] = [] + for point in result['polyline']: + # This poor man's validation code almost definately needs improving. + if type(point) == dict: + d['polyline'].append(dict(x=point['x'],y=point['y'],z=point['z'])) + if isinstance(result['color'], basestring): + d['strokeColor'] = result['color'] if "icon" in poi: d.update({"icon": poi['icon']}) if "createInfoWindow" in poi: diff --git a/overviewer_core/data/js_src/views.js b/overviewer_core/data/js_src/views.js index bbd75c1..2421b11 100644 --- a/overviewer_core/data/js_src/views.js +++ b/overviewer_core/data/js_src/views.js @@ -474,6 +474,22 @@ overviewer.views.SignControlView = Backbone.View.extend({ } } dataRoot[i].markerObjs.push(marker); + // Polyline stuff added by FreakusGeekus. Probably needs work. + if (typeof entity['polyline'] != 'undefined') { + var polypath = new Array(); + for (point in entity.polyline) { + polypath.push(overviewer.util.fromWorldToLatLng(entity.polyline[point].x, entity.polyline[point].y, entity.polyline[point].z, overviewer.mapView.options.currentTileSet)); + } + + var polyline = new google.maps.Polyline({ + 'path': polypath, + 'clickable': false, + 'map': overviewer.map, + 'visible': false, + 'strokeColor': entity['strokeColor'] + }); + dataRoot[i].markerObjs.push(polyline); + } } dataRoot[i].created = true; }