Skip to content

Commit

Permalink
Check if container is defined when setting marker pos.
Browse files Browse the repository at this point in the history
  • Loading branch information
pberkes committed Dec 11, 2012
1 parent 27ad961 commit 20a98a9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions mapping/enable/primitives/geo_primitive.py
Expand Up @@ -17,16 +17,18 @@ class GeoPrimitive(Shape):
def _get_position(self):
# Translate the geoposition to screen space
lat, lon = self.geoposition
if self.container: x, y = self.container.transformToScreen(lat, lon)
if self.container:
x, y = self.container.transformToScreen(lat, lon)
else: x, y = 0., 0.
# shift based on bounds
w, h = self.bounds
return x-w/2., y-h/2.

def _set_position(self, (x, y)):
lat_deg, lon_deg = self.container.transformToWGS84(x, y)
w, h = self.bounds
self.position = [x+w/2., y+h/2.]
if self.container:
lat_deg, lon_deg = self.container.transformToWGS84(x, y)
w, h = self.bounds
self.position = [x+w/2., y+h/2.]

def _draw_mainlayer(self, gc, view_bounds=None, mode='default'):
""" Draw the component. """
Expand Down

0 comments on commit 20a98a9

Please sign in to comment.