class EventProperties(SimplePanel): def __init__(self): SimplePanel.__init__(self) self.setSize('100%', '100%') self.myLatLng = LatLng(-25.363882, 131.044922) options = MapOptions() options.zoom = 4 options.center = self.myLatLng options.mapTypeId = MapTypeId.ROADMAP self.map = Map(self.getElement(), options) self.map.addListener("zoom_changed", self.zoomChanged) options = InfoWindowOptions() options.content = "Zoom Level Test" options.position = self.myLatLng self.infoWindow = InfoWindow(options) self.infoWindow.open(self.map) self.map.addListener("zoom_changed", self.zoomChanged) def zoomChanged(self): zoomLevel = self.map.get_zoom() self.map.setCenter(self.myLatLng) self.infoWindow.setContent("Zoom: " + str(zoomLevel)) if zoomLevel == 0: self.map.setZoom(10)
def attachSecretMessage(self, marker, number): message = ["This", "is", "the", "secret", "message"] options = InfoWindowOptions() options.content = message[number] infoWindow = InfoWindow(options) marker.addListener('click', lambda: infoWindow.open(self.map, marker))
class MapProgram: def onModuleLoad( self ): self.setUpInstanceVariables() self.assemblePanels() self.setUpListeners() self.service.usernames( self.userNameReceiver ) self.controlPanel.numPointsListBox.setSelectedIndex( 1 ) self.service.shakeevents( 'Last Week', self.controlPanel.nameListBox.getValue( self.controlPanel.nameListBox.getSelectedIndex() ), self.shakeEventPointReceiver ) def setUpInstanceVariables( self ): self.service = MapService() self.root = RootPanel() self.controlPanel = TopPanel() self.mapPanel = MapPanel() self.userNameReceiver = UserNameReceiver( self ) #self.usgsPointReceiver = USGSPointReceiver(self) self.shakeEventPointReceiver = ShakeEventPointReceiver( self ) self.markers = [] def assemblePanels( self ): vp = VerticalPanel() vp.add( self.controlPanel ) vp.add( self.mapPanel ) self.root.add( vp ) def setUpListeners( self ): npBox = self.controlPanel.numPointsListBox unBox = self.controlPanel.nameListBox def npFn(): #self.service.points(npBox.getValue(npBox.getSelectedIndex()),self.usgsPointReceiver) self.controlPanel.statusHTML.setHTML( 'Fetching Points...' ) self.service.shakeevents( npBox.getValue( npBox.getSelectedIndex() ), unBox.getValue( unBox.getSelectedIndex() ), self.shakeEventPointReceiver ) npBox.addChangeListener( npFn ) unBox.addChangeListener( npFn ) def mouseOverMarker( self,ind ): Window.alert('test1') marker = self.markers[ind] iwo = InfoWindowOptions() iwo.position = marker['latlng'] iwo.content = marker['title'] Window.alert('test2') self.iw = InfoWindow( iwo ) self.iw.open( self.mapPanel.map ) def mouseOutMarker( self ): self.iw.close()
def mouseOverMarker( self,ind ): Window.alert('test1') marker = self.markers[ind] iwo = InfoWindowOptions() iwo.position = marker['latlng'] iwo.content = marker['title'] Window.alert('test2') self.iw = InfoWindow( iwo ) self.iw.open( self.mapPanel.map )
def __init__(self): SimplePanel.__init__(self) self.setSize('100%', '100%') self.myLatLng = LatLng(-25.363882, 131.044922) options = MapOptions() options.zoom = 4 options.center = self.myLatLng options.mapTypeId = MapTypeId.ROADMAP self.map = Map(self.getElement(), options) self.map.addListener("zoom_changed", self.zoomChanged) options = InfoWindowOptions() options.content = "Zoom Level Test" options.position = self.myLatLng self.infoWindow = InfoWindow(options) self.infoWindow.open(self.map) self.map.addListener("zoom_changed", self.zoomChanged)