Ejemplo n.º 1
0
class EventArguments(SimplePanel):

    def __init__(self):
        SimplePanel.__init__(self)
        self.setSize('100%', '100%')

        options = MapOptions()
        options.zoom = 4
        options.center = LatLng(-25.363882, 131.044922)
        options.mapTypeId = MapTypeId.ROADMAP

        self.map = Map(self.getElement(), options)

        self.map.addListener("click", self.clicked)

    def clicked(self, event):
        print "clicked on " + str(event.latLng)
        self.placeMarker(event.latLng)

    def placeMarker(self, location):
        options = MarkerOptions()
        options.position = location
        options.map = self.map

        marker = Marker(options)

        self.map.setCenter(location)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
class EventSimple(SimplePanel):

    def __init__(self):
        SimplePanel.__init__(self)
        self.setSize('100%', '100%')

        options = MapOptions()
        options.zoom = 4
        options.center = LatLng(-25.363882, 131.044922)
        options.mapTypeId = MapTypeId.ROADMAP

        self.map = Map(self.getElement(), options)

        self.map.addListener("zoom_changed", self.zoomChanged)

        self.map.addListener("click", self.clicked)

    def zoomChanged(self):
        print "zoom to " + str(self.map.getZoom())
        Timer(1500, self.moveToDarwin)

    def moveToDarwin(self, timer):
        darwin = LatLng(-12.461334, 130.841904)
        self.map.setCenter(darwin)

    def clicked(self):
        self.map.setZoom(8)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
class EventSimple(SimplePanel):
    def __init__(self):
        SimplePanel.__init__(self)
        self.setSize("100%", "100%")

        options = MapOptions()
        options.zoom = 4
        options.center = LatLng(-25.363882, 131.044922)
        options.mapTypeId = MapTypeId.ROADMAP

        self.map = Map(self.getElement(), options)

        self.map.addListener("zoom_changed", self.zoomChanged)

        self.map.addListener("click", self.clicked)

    def zoomChanged(self):
        print "zoom to " + str(self.map.getZoom())
        Timer(1500, self.moveToDarwin)

    def moveToDarwin(self, timer):
        darwin = LatLng(-12.461334, 130.841904)
        self.map.setCenter(darwin)

    def clicked(self):
        self.map.setZoom(8)
Ejemplo n.º 6
0
class GeocodingSimple(DockPanel):
    def __init__(self):
        DockPanel.__init__(self)
        self.setSize('100%', '100%')

        self.geocoder = Geocoder()

        # widgets

        topPanel = HorizontalPanel()
        self.add(topPanel, DockPanel.NORTH)

        self.address = TextBox()
        self.address.setText("Sydney, NSW")
        self.address.addChangeListener(self.codeAddress)

        topPanel.add(self.address)

        button = Button("Geocode")
        button.addClickListener(self.codeAddress)

        topPanel.add(button)

        # now, the map

        mapPanel = SimplePanel()
        mapPanel.setSize('600', '400')
        self.add(mapPanel, DockPanel.CENTER)

        options = MapOptions(zoom=8,
                             center=LatLng(-34.397, 150.644),
                             mapTypeId=MapTypeId.ROADMAP)

        self.map = Map(mapPanel.getElement(), options)

    def codeAddress(self):
        address = self.address.getText()

        print "codeAddress ", address

        if self.geocoder:
            request = GeocoderRequest(address=address)
            self.geocoder.geocode(request, self.geocodeResult)

    def geocodeResult(self, results, status):
        print "geocodeResult"

        if status == GeocoderStatus.OK:

            for res in results:
                print res.formatted_address
                print res.geometry.location.lat()
                print res.geometry.location.lng()
                for compo in res.address_components:
                    print "- " + compo.short_name
                print ""

            self.map.setCenter(results[0].geometry.location)

            marker = Marker(
                MarkerOptions(map=self.map,
                              position=results[0].geometry.location))

        else:
            Window.alert(
                "Geocode was not successful for the following reason: " +
                status)
Ejemplo n.º 7
0
class GeocodingSimple(DockPanel):

    def __init__(self):
        DockPanel.__init__(self)
        self.setSize('100%', '100%')

        self.geocoder = Geocoder()

        # widgets

        topPanel = HorizontalPanel()
        self.add(topPanel, DockPanel.NORTH)

        self.address = TextBox()
        self.address.setText("Sydney, NSW")
        self.address.addChangeListener(self.codeAddress)

        topPanel.add(self.address)

        button = Button("Geocode")
        button.addClickListener(self.codeAddress)

        topPanel.add(button)

        # now, the map

        mapPanel = SimplePanel()
        mapPanel.setSize('600', '400')
        self.add(mapPanel, DockPanel.CENTER)

        options = MapOptions(zoom=8, center=LatLng(-34.397, 150.644),
                           mapTypeId=MapTypeId.ROADMAP)

        self.map = Map(mapPanel.getElement(), options)

    def codeAddress(self):
        address = self.address.getText()

        print "codeAddress ", address

        if self.geocoder:
            request = GeocoderRequest(address=address)
            self.geocoder.geocode(request, self.geocodeResult)

    def geocodeResult(self, results, status):
        print "geocodeResult"

        if status == GeocoderStatus.OK:

            for res in results:
                print res.formatted_address
                print res.geometry.location.lat()
                print res.geometry.location.lng()
                for compo in res.address_components:
                    print "- " + compo.short_name
                print ""

            self.map.setCenter(results[0].geometry.location)

            marker = Marker(MarkerOptions(map=self.map,
                position=results[0].geometry.location))

        else:
            Window.alert(
                "Geocode was not successful for the following reason: " +
                status)