예제 #1
0
def get_loc_map(event: Event = None, current_play_time: Optional[EventPlayTimes] = None, style: str = "height:600px;width:730px;margin:8;"):
    initial_zoom = 13
    if not event:
        return Map(
            zoom=initial_zoom,
            identifier="loc_map",
            lat=0,
            lng=0,
            style=style,
            language=current_user.language
        )
    initial_location = nominatim.geocode(event.creator.city)
    init_lat = initial_location.latitude if initial_location else None
    init_lng = initial_location.longitude if initial_location else None
    markers = []
    if current_play_time is not None:
        location = Location.get(current_play_time.location_id)
        if location is not None:
            markers.append((location.latitude, location.longitude))
            init_lat = location.latitude
            init_lng = location.longitude
            initial_zoom = 14.5
    return Map(
        zoom=initial_zoom,
        identifier="loc_map",
        lat=init_lat,
        lng=init_lng,
        style=style,
        language=current_user.language,
        markers=markers
    )
예제 #2
0
def rectangle_view():
    rectangle = {
        "stroke_color": "#0000FF",
        "stroke_opacity": 0.8,
        "stroke_weight": 5,
        "fill_color": "#FFFFFF",
        "fill_opacity": 0.1,
        "bounds": {
            "north": 33.685,
            "south": 33.671,
            "east": -116.234,
            "west": -116.251,
        },
    }

    rectmap = Map(
        identifier="rectmap",
        varname="rectmap",
        lat=33.678,
        lng=-116.243,
        rectangles=[
            rectangle,
            [33.678, -116.243, 33.671, -116.234],
            (33.685, -116.251, 33.678, -116.243),
            [(33.679, -116.254), (33.678, -116.243)],
            ([33.689, -116.260], [33.685, -116.250]),
        ],
    )

    return jsonify(rectmap.as_json())
예제 #3
0
파일: maps.py 프로젝트: rsaavy/CH4
def mapview():
    data = genMarkerData(touchtunes_events_pnda)
    indices = getSongAmt(touchtunes_events_pnda)

    sndmap0 = Map(
        identifier="sndmap0",
        lat=data[indices[0]]['lat'],
        lng=data[indices[0]]['lng'],
        style="height:700px;width:700px;margin:0;",
        markers=genMarkerData(touchtunes_events_pnda)[0:indices[1]]
        )
    sndmap1 = Map(
        identifier="sndmap1",
        lat=data[indices[1]+1]['lat'],
        lng=data[indices[1]+1]['lng'],
        style="height:700px;width:700px;margin:0;",
        markers=genMarkerData(touchtunes_events_pnda)[indices[1]:indices[2]]
        )
    sndmap2 = Map(
        identifier="sndmap2",
        lat=data[indices[2]+1]['lat'],
        lng=data[indices[2]+1]['lng'],
        style="height:700px;width:700px;margin:0;",
        markers=genMarkerData(touchtunes_events_pnda)[indices[2]:indices[3]]
        )
    sndmap3 = Map(
        identifier="sndmap3",
        lat=data[indices[3]+1]['lat'],
        lng=data[indices[3]+1]['lng'],
        style="height:700px;width:700px;margin:0;",
        markers=genMarkerData(touchtunes_events_pnda)[indices[3]:]
        )
    return render_template('map.html', sndmap0=sndmap0, sndmap1=sndmap1, sndmap2=sndmap2, sndmap3=sndmap3)
예제 #4
0
def simple_view_three():
    trdmap = Map(
        identifier="trdmap",
        varname="trdmap",
        lat=37.4419,
        lng=-122.1419,
        markers=[
            {
                'icon': icons.alpha.B,
                'lat': 37.4419,
                'lng': -122.1419,
                'infobox': "Hello I am <b style='color:green;'>GREEN</b>!"
            },
            {
                'icon': icons.dots.blue,
                'lat': 37.4300,
                'lng': -122.1400,
                'infobox': "Hello I am <b style='color:blue;'>BLUE</b>!"
            },
            {
                'icon': '//maps.google.com/mapfiles/ms/icons/yellow-dot.png',
                'lat': 37.4500,
                'lng': -122.1350,
                'infobox': (
                    "Hello I am <b style='color:#ffcc00;'>YELLOW</b>!"
                    "<h2>It is HTML title</h2>"
                    "<img src='//placehold.it/50'>"
                    "<br>Images allowed!"
                )
            }
        ]
    )

    return jsonify(trdmap.as_json())
예제 #5
0
def simple_view_three():
    trdmap = Map(
        identifier="trdmap",
        varname="trdmap",
        lat=37.4419,
        lng=-122.1419,
        markers=[
            {
                'icon': icons.alpha.B,
                'lat': 37.4419,
                'lng': -122.1419,
                'infobox': "Hello I am <b style='color:green;'>GREEN</b>!"
            },
            {
                'icon': icons.dots.blue,
                'lat': 37.4300,
                'lng': -122.1400,
                'infobox': "Hello I am <b style='color:blue;'>BLUE</b>!"
            },
            {
                'icon': '//maps.google.com/mapfiles/ms/icons/yellow-dot.png',
                'lat': 37.4500,
                'lng': -122.1350,
                'infobox': (
                    "Hello I am <b style='color:#ffcc00;'>YELLOW</b>!"
                    "<h2>It is HTML title</h2>"
                    "<img src='//placehold.it/50'>"
                    "<br>Images allowed!"
                )
            }
        ]
    )

    return jsonify(trdmap.as_json())
def rectangle_view():
    rectangle = {
        "stroke_color": "#0000FF",
        "stroke_opacity": 0.8,
        "stroke_weight": 5,
        "fill_color": "#FFFFFF",
        "fill_opacity": 0.1,
        "bounds": {"north": 33.685, "south": 33.671, "east": -116.234, "west": -116.251},
    }

    rectmap = Map(
        identifier="rectmap",
        varname="rectmap",
        lat=33.678,
        lng=-116.243,
        rectangles=[
            rectangle,
            [33.678, -116.243, 33.671, -116.234],
            (33.685, -116.251, 33.678, -116.243),
            [(33.679, -116.254), (33.678, -116.243)],
            ([33.689, -116.260], [33.685, -116.250]),
        ],
    )

    return jsonify(rectmap.as_json())
예제 #7
0
def cluster_view():
    clustermap = Map(identifier="clustermap",
                     varname="clustermap",
                     lat=37.4419,
                     lng=-122.1419,
                     markers=[{
                         'lat': 37.4500,
                         'lng': -122.1350
                     }, {
                         'lat': 37.4400,
                         'lng': -122.1350
                     }, {
                         'lat': 37.4300,
                         'lng': -122.1350
                     }, {
                         'lat': 36.4200,
                         'lng': -122.1350
                     }, {
                         'lat': 36.4100,
                         'lng': -121.1350
                     }],
                     zoom=12,
                     cluster=True)

    return jsonify(clustermap.as_json())
예제 #8
0
파일: app.py 프로젝트: Kabmichal/PIS
def zobraz_main_page():
    name = current_user.name
    adresa = pobocka.service.getById(current_user.pobocka_id)
    suradnice = lokacia.service.searchByName(adresa.adresa)
    print(suradnice)
    lat = suradnice[0]['coord_lat']
    lon = suradnice[0]['coord_lon']
    mymap = Map(identifier="view-side", lat=lat, lng=lon, markers=[(lat, lon)])
    sndmap = Map(identifier="sndmap",
                 lat=lat,
                 lng=lon,
                 markers=[{
                     'icon':
                     'http://maps.google.com/mapfiles/ms/icons/green-dot.png',
                     'lat': lat,
                     'lng': lon,
                     'infobox': "<b>Hello World</b>"
                 }, {
                     'icon':
                     'http://maps.google.com/mapfiles/ms/icons/blue-dot.png',
                     'lat': lat,
                     'lng': lon,
                     'infobox': "<b>Hello World from other place</b>"
                 }])
    return render_template('after_login.html',
                           mymap=mymap,
                           sndmap=sndmap,
                           name=name,
                           adresa=adresa,
                           lat=lat,
                           lon=lon)
예제 #9
0
def makeppl():
    print('mapview')
    food = get_items(FOOD)
    hygiene = get_items(HYGIENE)
    listoflist = [*food, *hygiene]

    mymap = Map(identifier="view-side",
                lat=53.5461,
                lng=-113.4938,
                markers=[(53.5461, -113.4938)])

    markers2 = []
    for _ in range(1, 19):
        lat = random.randrange(5346000, 5363000) / 100000
        lng = random.randrange(11342000, 11361000) / 100000
        lng = -lng

        markers2.append({
            "icon": "http://maps.google.com/mapfiles/ms/icons/red-dot.png",
            "lat": lat,
            "lng": lng,
            "infobox": make_person(),
        })

    sndmap = Map(identifier="sndmap",
                 lat=53.5461,
                 lng=-113.4938,
                 style="height:600px;width:100%;margin:0;",
                 markers=markers2)

    return render_template("example.html",
                           mymap=mymap,
                           sndmap=sndmap,
                           listoflist=listoflist)
예제 #10
0
def mapsos():
    location = "/Users/amirulislam/Downloads/"
    lat = read_from_file(location + "lat")
    lon = read_from_file(location + "lon")
    sos_msg = read_from_file(location + "sos_msg")

    # creating a map in the view
    mymap = Map(identifier="view-side", lat=lat, lng=lon, markers=[(lat, lon)])
    sndmap = Map(
        identifier="sndmap",
        lat=lat,
        lng=lon,
        markers=
        [{
            'icon': 'http://maps.google.com/mapfiles/ms/icons/green-dot.png',
            'lat': lat,
            'lng': lon,
            'infobox': "<b>" + sos_msg + "</b>"
        }
         # ,
         # {
         # 'icon': 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png',
         # 'lat': 37.4300,
         # 'lng': -122.1400,
         # 'infobox': "<b>Hello World from other place</b>"
         # }
         ])
    return render_template('index.html', mymap=mymap, sndmap=sndmap)
def polygon_view():
    polygon = {
        "stroke_color": "#0AB0DE",
        "stroke_opacity": 1.0,
        "stroke_weight": 3,
        "fill_color": "#ABC321",
        "fill_opacity": 0.5,
        "path": [
            {"lat": 33.678, "lng": -116.243},
            {"lat": 33.679, "lng": -116.244},
            {"lat": 33.680, "lng": -116.250},
            {"lat": 33.681, "lng": -116.239},
            {"lat": 33.678, "lng": -116.243},
        ],
    }

    path1 = [(33.665, -116.235), (33.666, -116.256), (33.667, -116.250), (33.668, -116.229)]

    path2 = ((33.659, -116.243), (33.660, -116.244), (33.649, -116.250), (33.644, -116.239))

    path3 = ([33.688, -116.243], [33.680, -116.244], [33.682, -116.250], [33.690, -116.239])

    path4 = [[33.690, -116.243], [33.691, -116.244], [33.692, -116.250], [33.693, -116.239]]

    pgonmap = Map(
        identifier="pgonmap",
        varname="pgonmap",
        lat=33.678,
        lng=-116.243,
        polygons=[polygon, path1, path2, path3, path4],
    )

    return jsonify(pgonmap.as_json())
예제 #12
0
def engineerHome():
    """
    Routing to engineer's page
    """
    if ("user" in session) and (session["position"] == "engineer"):
        engineerHome = session["user"]
        # Create map of reported cars
        from main import googlemaps, ReportedCar
        markers = ReportedCar.query.with_entities(ReportedCar.latitude, ReportedCar.longitude).all()
        if len(markers) > 0:
            maintenance_map = Map(
                identifier="view-side",
                lat=markers[0][0],
                lng=markers[0][1],
                markers=markers,
                fit_markers_to_bounds=True
            )
        else:
            maintenance_map = Map(
                identifier="view-map",
                # RMIT latitude and longitude
                lat=10.7294,
                lng=106.6931
            )

        return render_template("engineer.html", engineerHome=engineerHome, maintenance_map=maintenance_map)
    else:
        return redirect(url_for("login"))
예제 #13
0
 def config_test(self):
     self.google_map = Map(
         identifier="view-side",  # for DOM element
         varname="mymap",  # for JS object name
         lat=37.4419,
         lng=-122.1419,
     )
예제 #14
0
파일: views.py 프로젝트: Tiierr/Distance
def googlemapview(latlng):
    form = SearchForm()
    if form.validate_on_submit():
        location = form.location.data
        distance = GoogleDistance(location)
        if distance.status == 'ZERO_RESULTS':
            abort(404)
        relatlng = distance.relatlng
        latlng = distance.latlng
        return redirect(url_for('.googlemapview', latlng=latlng + relatlng))
    home = Map(identifier="home",
               lat=latlng[0],
               lng=latlng[1],
               markers=[
                   {
                       'lat': latlng[0],
                       'lng': latlng[1],
                       'infobox': ListToString(latlng[:2]).toString()
                   },
               ])

    destination = Map(identifier="destination",
                      lat=latlng[2],
                      lng=latlng[3],
                      markers=[
                          {
                              'lat': latlng[2],
                              'lng': latlng[3],
                              'infobox': ListToString(latlng[2:]).toString()
                          },
                      ])
    return render_template('gmap.html',
                           home=home,
                           destination=destination,
                           form=form)
예제 #15
0
def polygon_view():
    polygon = {
        'stroke_color': '#0AB0DE',
        'stroke_opacity': 1.0,
        'stroke_weight': 3,
        'fill_color': '#ABC321',
        'fill_opacity': .5,
        'path': [{'lat': 33.678, 'lng': -116.243},
                 {'lat': 33.679, 'lng': -116.244},
                 {'lat': 33.680, 'lng': -116.250},
                 {'lat': 33.681, 'lng': -116.239},
                 {'lat': 33.678, 'lng': -116.243}]
    }

    path1 = [(33.665, -116.235), (33.666, -116.256),
             (33.667, -116.250), (33.668, -116.229)]

    path2 = ((33.659, -116.243), (33.660, -116.244),
             (33.649, -116.250), (33.644, -116.239))

    path3 = ([33.688, -116.243], [33.680, -116.244],
             [33.682, -116.250], [33.690, -116.239])

    path4 = [[33.690, -116.243], [33.691, -116.244],
             [33.692, -116.250], [33.693, -116.239]]

    pgonmap = Map(
        identifier="pgonmap",
        varname="pgonmap",
        lat=33.678,
        lng=-116.243,
        polygons=[polygon, path1, path2, path3, path4]
    )

    return jsonify(pgonmap.as_json())
예제 #16
0
def rectangle_view():
    rectangle = {
        'stroke_color': '#0000FF',
        'stroke_opacity': .8,
        'stroke_weight': 5,
        'fill_color': '#FFFFFF',
        'fill_opacity': .1,
        'bounds': {
                  'north': 33.685,
                  'south': 33.671,
                  'east': -116.234,
                  'west': -116.251
        }
    }

    rectmap = Map(
        identifier="rectmap",
        varname="rectmap",
        lat=33.678,
        lng=-116.243,
        rectangles=[
            rectangle,
            [33.678, -116.243, 33.671, -116.234],
            (33.685, -116.251, 33.678, -116.243),
            [(33.679, -116.254), (33.678, -116.243)],
            ([33.689, -116.260], [33.685, -116.250]),
        ]
    )

    return jsonify(rectmap.as_json())
예제 #17
0
def circle_view():
    circle = {
        'stroke_color': '#FF00FF',
        'stroke_opacity': 1.0,
        'stroke_weight': 7,
        'fill_color': '#FFFFFF',
        'fill_opacity': .8,
        'center': {
                  'lat': 33.685,
                  'lng': -116.251
        },
        'radius': 2000,
    }

    circlemap = Map(
        identifier="circlemap",
        varname="circlemap",
        lat=33.678,
        lng=-116.243,
        circles=[
            circle,
            [33.685, -116.251, 1000],
            (33.685, -116.251, 1500),
        ]
    )

    return jsonify(circlemap.as_json())
예제 #18
0
def rectangle_view():
    rectangle = {
        'stroke_color': '#0000FF',
        'stroke_opacity': .8,
        'stroke_weight': 5,
        'fill_color': '#FFFFFF',
        'fill_opacity': .1,
        'bounds': {
            'north': 33.685,
            'south': 33.671,
            'east': -116.234,
            'west': -116.251
        }
    }

    rectmap = Map(identifier="rectmap",
                  varname="rectmap",
                  lat=33.678,
                  lng=-116.243,
                  rectangles=[
                      rectangle,
                      [33.678, -116.243, 33.671, -116.234],
                      (33.685, -116.251, 33.678, -116.243),
                      [(33.679, -116.254), (33.678, -116.243)],
                      ([33.689, -116.260], [33.685, -116.250]),
                  ])

    return jsonify(rectmap.as_json())
예제 #19
0
def mapview():

    send_url = "http://api.ipstack.com/check?access_key=fe105aaf529b654e755358dbad59d647"
    geo_req = requests.get(send_url)
    geo_json = json.loads(geo_req.text)
    latitude = geo_json['latitude']
    longitude = geo_json['longitude']
    city = geo_json['city']

    # creating a map in the view
    mymap = Map(identifier="view-side",
                lat=latitude,
                lng=longitude,
                markers=[(latitude, longitude)])
    sndmap = Map(identifier="sndmap",
                 lat=37.4419,
                 lng=-122.1419,
                 markers=[{
                     'icon':
                     'http://maps.google.com/mapfiles/ms/icons/green-dot.png',
                     'lat': 37.4419,
                     'lng': -122.1419,
                     'infobox': "<b>Hello World</b>"
                 }, {
                     'icon':
                     'http://maps.google.com/mapfiles/ms/icons/blue-dot.png',
                     'lat': 37.4300,
                     'lng': -122.1400,
                     'infobox': "<b>Hello World from other place</b>"
                 }])
    return render_template('templates/example.html',
                           mymap=mymap,
                           sndmap=sndmap)
예제 #20
0
def mapview():
    # creating a map in the view
    mymap = Map(
        identifier="view-side",
        lat=33.4419,
        lng=-116.1419,
        markers=[(33.4419, -116.1419)]
    )
    sndmap = Map(
        identifier="sndmap",
        lat=33.4419,
        lng=-116.1419,
        zoom=10,
        style="height:800px;width:800px;margin:0;",
        markers=[
          {
             'icon': 'http://maps.google.com/mapfiles/ms/icons/green-dot.png',
             'lat': 33.4419,
             'lng': -116.1419,
             'infobox': "<b>Hello World</b>"
          },
          {
             'icon': 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png',
             'lat': 33.4300,
             'lng': -116.1400,
             'infobox': "<b>Hello World from other place</b>"
          }
        ],
        polylines=polylines
    )
    return render_template('venues.html', mymap=mymap, sndmap=sndmap)
예제 #21
0
def polygon_view():
    polygon = {
        'stroke_color': '#0AB0DE',
        'stroke_opacity': 1.0,
        'stroke_weight': 3,
        'fill_color': '#ABC321',
        'fill_opacity': .5,
        'path': [{'lat': 33.678, 'lng': -116.243},
                 {'lat': 33.679, 'lng': -116.244},
                 {'lat': 33.680, 'lng': -116.250},
                 {'lat': 33.681, 'lng': -116.239},
                 {'lat': 33.678, 'lng': -116.243}]
    }

    path1 = [(33.665, -116.235), (33.666, -116.256),
             (33.667, -116.250), (33.668, -116.229)]

    path2 = ((33.659, -116.243), (33.660, -116.244),
             (33.649, -116.250), (33.644, -116.239))

    path3 = ([33.688, -116.243], [33.680, -116.244],
             [33.682, -116.250], [33.690, -116.239])

    path4 = [[33.690, -116.243], [33.691, -116.244],
             [33.692, -116.250], [33.693, -116.239]]

    pgonmap = Map(
        identifier="pgonmap",
        varname="pgonmap",
        lat=33.678,
        lng=-116.243,
        polygons=[polygon, path1, path2, path3, path4]
    )

    return jsonify(pgonmap.as_json())
예제 #22
0
def mapview():

    sfCenter = [37.7749, -122.4194]

    mymap = Map(identifier="view-side",
                lat=sfCenter[0],
                lng=sfCenter[1],
                maptype='ROADMAP',
                markers=[(37.7749, -122.4194)])
    sndmap = Map(identifier="sndmap",
                 lat=37.4419,
                 lng=-122.1419,
                 markers=[{
                     'icon':
                     'http://maps.google.com/mapfiles/ms/icons/green-dot.png',
                     'lat': 37.4419,
                     'lng': -122.1419,
                     'infobox': "<b>Hello World</b>"
                 }, {
                     'icon':
                     'http://maps.google.com/mapfiles/ms/icons/blue-dot.png',
                     'lat': 37.4300,
                     'lng': -122.1400,
                     'infobox': "<b>Hello World from other place</b>"
                 }])

    #### LIST OF DICTIONARIES TO PASS AS MARKERS
    markers3 = convert_loc_to_markers(
        [sfCenter, [37.78089, -122.40886], [37.78213, -122.41171]])

    thrdmap = Map(identifier="thrdmap",
                  lat=sfCenter[0],
                  lng=sfCenter[1],
                  maptype="ROADMAP",
                  markers=markers3)
예제 #23
0
def circle_view():
    circle = {
        'stroke_color': '#FF00FF',
        'stroke_opacity': 1.0,
        'stroke_weight': 7,
        'fill_color': '#FFFFFF',
        'fill_opacity': .8,
        'center': {
            'lat': 33.685,
            'lng': -116.251
        },
        'radius': 2000,
    }

    circlemap = Map(identifier="circlemap",
                    varname="circlemap",
                    lat=33.678,
                    lng=-116.243,
                    circles=[
                        circle,
                        [33.685, -116.251, 1000],
                        (33.685, -116.251, 1500),
                    ])

    return jsonify(circlemap.as_json())
예제 #24
0
def map():
    import crime_data
    a, marker = crime_data.crimedata()

    # creating a map in the view
    mymap = Map(
        identifier="view-side",
        lat=37.4419,
        lng=-122.1419,
        markers=[(37.4419, -122.1419)]
    )
    sndmap = Map(
        identifier="moon",
        lat= a['GEO_LAT'],
        lng= a['GEO_LON'],
        language='ko',
        style=(
            "height:100%;"
            "width:100%;"
            "top:64;"
            "left:0;"
            "position:absolute;"
            "z-index:200;"
        ),
         markers = marker
    )
    dt = datetime(2018,7, 20)
    return render_template('map.html', sndmap=sndmap, dt=dt)
예제 #25
0
def cluster_view():
    clustermap = Map(
        identifier="clustermap",
        varname="clustermap",
        lat=37.4419,
        lng=-122.1419,
        markers=[
            {
                'lat': 37.4500,
                'lng': -122.1350
            },
            {
                'lat': 37.4400,
                'lng': -122.1350
            },
            {
                'lat': 37.4300,
                'lng': -122.1350
            },
            {
                'lat': 36.4200,
                'lng': -122.1350
            },
            {
                'lat': 36.4100,
                'lng': -121.1350
            }
        ],
        zoom=12,
        cluster=True
    )

    return jsonify(clustermap.as_json())
예제 #26
0
    def index():

        engine = create_engine(config.SQLALCHEMY_DATABASE_URI_LOCAL)
        connection = engine.connect()

        mymap = Map(
            identifier="view-side",
            lat=27.4419,
            lng=-112.1419,
        )

        markers = []
        rows = connection.execute(
            "SELECT latitude,longitude,callsign,datetime \
            FROM (SELECT   t.*, MAX(datetime) OVER (partition BY callsign) maxdatetime \
            FROM PUBLIC.trace AS t) AS tt \
            WHERE tt.datetime=tt.maxdatetime \
            ORDER BY callsign").fetchall()

        for row in rows:
            markers.append({
                'icon': 'http://maps.google.com/mapfiles/ms/icons/plane.png',
                'lat': row[0],
                'lng': row[1],
                'infobox': f"<b>{row[2]}</b>"
            })

        sndmap = Map(identifier="sndmap",
                     lat=55.9000,
                     lng=37.7800,
                     markers=markers,
                     zoom=3,
                     style="height:720px;width:1100px;margin:0;")

        return render_template('index.html', mymap=mymap, sndmap=sndmap)
예제 #27
0
def mapview():
    # creating a map in the view
    mymap = Map(
        identifier="view-side",
        lat=37.4419,
        lng=-122.1419,
        markers=[(37.4419, -122.1419)]
    )
    sndmap = Map(
        identifier="sndmap",
        lat=37.4419,
        lng=-122.1419,
        markers=[
            {
                'icon': 'http://maps.google.com/mapfiles/ms/icons/green-dot.png',
                'lat': 37.4419,
                'lng': -122.1419,
                'infobox': "<b>Hello World</b>"
            },
            {
                'icon': 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png',
                'lat': 37.4300,
                'lng': -122.1400,
                'infobox': "<b>Hello World from other place</b>"
            }
        ]
    )
    return render_template('map.html', mymap=mymap, sndmap=sndmap)
예제 #28
0
def mapview():
    location = NearByLocations()
    location.locations = []
    location.findServices(request.form['Town'], request.form['Service'])
    mymap = None
    if len(location.locations) == 0:
        mymap = Map(style="width: 100vw; height: 100vh;",
                    identifier="view-side",
                    lat=41.6032,
                    lng=-73.0877,
                    markers=[])
    else:
        markers = []
        if request.form['Service'] == "Care Facilities":
            for entry in location.locations:
                markers.append({
                    'icon':
                    '/static/images/doc.png',
                    'lat':
                    entry.location['lat'],
                    'lng':
                    entry.location['lng'],
                    'infobox':
                    "<b>" + entry.name + "</b>" + "</br>" + entry.address
                })
        elif request.form['Service'] == "Drop Box":
            for entry in location.locations:
                markers.append({
                    'icon':
                    '/static/images/box.png',
                    'lat':
                    entry.location[0],
                    'lng':
                    entry.location[1],
                    'infobox':
                    "<b>" + entry.name + "</b></br>" + entry.address
                })
        else:
            for entry in location.locations:
                markers.append({
                    'icon':
                    '/static/images/pharmacy.png',
                    'lat':
                    entry.location['coordinates'][1],
                    'lng':
                    entry.location['coordinates'][0],
                    'infobox':
                    "<b>" + entry.name + "</b></br>" + entry.phoneNumber +
                    "</br>" + entry.address
                })
    # creating a map in the view
        mymap = Map(style="width: 100vw; height: 100vh;",
                    identifier="view-side",
                    lat=markers[0]['lat'],
                    lng=markers[0]['lng'],
                    markers=markers)
    return render_template('pages/index.html',
                           mymap=mymap,
                           prevValue=request.form['Town'])
예제 #29
0
def cars():
    if session['type'] == 'c':
        mark = []
        cars = mainEngine.listAvailableCars()
        for car in cars:
            print(car[5])
            x = car[5].split(",")
            mark.append((float(x[1]), float(x[2]), car[1]))
        gmap = Map(
            identifier="gmap",
            varname="gmap",
            #MELBOURNE COORDINATE
            lat=-37.8136,
            lng=144.9631,
            markers={
                icons.dots.blue: mark,
            },
            style=
            "height:300px;width:300px;margin:0;margin-left:auto;margin-right:auto;",
        )
        return render_template("customer/carlist.html", cars=cars, gmap=gmap)
    elif session['type'] == 'a':
        mark = []
        cars = mainEngine.listCars()
        for car in cars:
            x = car[5].split(",")
            mark.append((float(x[1]), float(x[2]), car[1]))
        gmap = Map(
            identifier="gmap",
            varname="gmap",
            #MELBOURNE COORDINATE
            lat=-37.8136,
            lng=144.9631,
            markers={
                icons.dots.blue: mark,
            },
            style=
            "height:300px;width:300px;margin:0;margin-left:auto;margin-right:auto;",
        )
        return render_template("admin/carlist.html", cars=cars, gmap=gmap)
    elif session['type'] == 'e':
        mark = []
        cars = mainEngine.listBrokenCars()
        for car in cars:
            x = car[5].split(",")
            mark.append((float(x[1]), float(x[2]), car[1]))
        gmap = Map(
            identifier="gmap",
            varname="gmap",
            #MELBOURNE COORDINATE
            lat=-37.8136,
            lng=144.9631,
            markers={
                icons.dots.blue: mark,
            },
            style=
            "height:300px;width:300px;margin:0;margin-left:auto;margin-right:auto;",
        )
        return render_template("engineer/carlist.html", cars=cars, gmap=gmap)
예제 #30
0
def simple_view_one():
    mymap = Map(
        identifier="view-side",  # for DOM element
        varname="mymap",  # for JS object name
        lat=37.4419,
        lng=-122.1419,
        markers=[(37.4419, -122.1419)])
    return jsonify(mymap.as_json())
예제 #31
0
def icms():
    form = InfoForm()
    if form.is_submitted():
        formResult = request.form.to_dict()
        dictToJson = formResultParser(formResult)
        if formResult["hour"] == '':
            print("visit now")
            print(dictToJson)
            res = requests.post(
                'https://app-tier1-latest-collections.uc.r.appspot.com/places',
                json=dictToJson)
            print(str(res))
            if str(res) != '<Response [200]>':
                res = requests.post(
                    'https://app-tier1-latest-collections.uc.r.appspot.com/places',
                    json=dictToJson)
            print(res)
        else:
            dictToJson["hour"] = int(formResult["hour"][:2])
            dictToJson["day"] = datetime.strptime(formResult["day"],
                                                  "%Y-%m-%d").strftime('%a')
            # call to analytics url
            res = requests.post(
                'https://app-tier2-analytics-collection.uc.r.appspot.com/analytics',
                json=dictToJson)
            if str(res) != '<Response [200]>':
                res = requests.post(
                    'https://app-tier2-analytics-collection.uc.r.appspot.com/analytics',
                    json=dictToJson)
            print(res)
        response_data = res.json()
        # print(response_data)

        markers_list, result_list, placeid_result_dict, message = responseParser(
            response_data, formResult["location"], formResult["qtype"],
            formResult["hour"])
        #########################################################################################
        mymap = Map(
            identifier="view-side",
            lat=37.4419,
            lng=-122.1419,
            # markers=[(loc['icon'],loc['lat'], loc['lng'], loc['infobox']) for loc in markers_list]
        )
        sndmap = Map(identifier="sndmap",
                     lat=33.4166117,
                     lng=-111.9235453,
                     markers=list(loc for loc in markers_list),
                     fit_markers_to_bounds=True)
        queryType = formResult["qtype"].capitalize()
        return render_template('example.html',
                               mymap=mymap,
                               sndmap=sndmap,
                               recommendations=result_list,
                               firstResult=placeid_result_dict,
                               qtype=queryType,
                               message=message)

    return render_template('display.html', form=form)
예제 #32
0
def simple_view_one():
    mymap = Map(
        identifier="view-side",  # for DOM element
        varname="mymap",  # for JS object name
        lat=37.4419,
        lng=-122.1419,
        markers=[(37.4419, -122.1419)]
    )
    return jsonify(mymap.as_json())
예제 #33
0
def mapview():
    # creating a map in the view

    data = [
            {
                'icon': 'http://bousai4-boaarmpit.c9users.io/static/img/srd_icon_yellow.png',
                'lat': 35.680795,
                'lng': 139.734105,
                'infobox': "<img src='http://bousai4-boaarmpit.c9users.io/static/img/upload/2017-01-22_152749_4.jpg' width='100' height='100' />",
            }
        ]
    #data.append({'icon':'http://bousai4-boaarmpit.c9users.io/static/img/upload/test/srd_icon_green.png', 'lat': 35.675438, 'lng': 139.782242, 'infobox': "<img src='http://bousai4-boaarmpit.c9users.io/static/img/upload/test/2017-01-21_194026.jpg' width='100' height='100' />", })

    # connector = psycopg2.connect(host="localhost:5432", database="sample", user="******", password="******")

    cursor = connector.cursor()
    #sql = "SELECT mobile.mid AS mid, mobile.interval AS created_at, (SELECT lat FROM location WHERE mobile.interval::timestamp <= created_at::timestamp ORDER BY created_at ASC LIMIT 1) AS lat, (SELECT lng FROM location WHERE mobile.interval::timestamp <= created_at::timestamp ORDER BY created_at ASC LIMIT 1) AS lng, (SELECT path FROM photo WHERE mobile.interval::timestamp <= created_at::timestamp ORDER BY created_at ASC LIMIT 1) AS infobox FROM danger_mid AS mobile WHERE danger = 1"
    # sql = "SELECT interval, danger, face, movement, voice, (SELECT lat FROM location WHERE mobile.interval::timestamp <= created_at::timestamp ORDER BY created_at ASC LIMIT 1) AS lat, (SELECT lng FROM location WHERE mobile.interval::timestamp <= created_at::timestamp ORDER BY created_at ASC LIMIT 1) AS lng, (SELECT path FROM photo WHERE mobile.interval::timestamp <= created_at::timestamp ORDER BY created_at ASC LIMIT 1) AS infobox FROM danger_mid as mobile"
    # cursor.execute(sql)
    # result = cursor.fetchall()


    # count = 0
    # for place in result:
    #     face=int(place[2])
    #     movement=int(place[3])
    #     voice=int(place[4])
    #     if place[5] is not None:
    #         if(face == 0):
    #             data.append({'icon':'http://bousai4-boaarmpit.c9users.io/static/img/srd_icon_green.png', 'lat': place[5], 'lng': place[6], 'infobox': "<img src='http://bousai4-boaarmpit.c9users.io/static/img/upload/"+ place[7].replace("/photo", "") + "' width='100' height='100' />"})
    #         elif(movement+voice == 0):
    #             data.append({'icon':'http://bousai4-boaarmpit.c9users.io/static/img/srd_icon_red.png', 'lat': place[5], 'lng': place[6], 'infobox': "<img src='http://bousai4-boaarmpit.c9users.io/static/img/upload/"+ place[7].replace("/photo", "") + "' width='100' height='100' />"})
    #         elif(movement+voice >= 1):
    #             data.append({'icon':'http://bousai4-boaarmpit.c9users.io/static/img/srd_icon_yellow.png', 'lat': place[5], 'lng': place[6], 'infobox': "<img src='http://bousai4-boaarmpit.c9users.io/static/img/upload/"+ place[7].replace("/photo", "") + "' width='100' height='100' />"})
    #         else:
    #             data.append({'icon':'http://bousai4-boaarmpit.c9users.io/static/img/srd_icon_black.png', 'lat': place[5], 'lng': place[6], 'infobox': "<img src='http://bousai4-boaarmpit.c9users.io/static/img/upload/"+ place[7].replace("/photo", "") + "' width='100' height='100' />"})
    #     count = count + 1
    # cursor.close()
    # connector.close()

    mymap = Map(
        identifier="view-side",
        lat=35.680795,
        lng=139.734105,
        markers=[(35.680795, 139.734105)]
    )
    sndmap = Map(
        identifier="sndmap",
        lat=35.680795,
        lng=139.734105,
        style="border:solid 2px #0a0a0a;height:600px;width:1400px;margin:20;color:rgba(0,0,0,0.1)",
        markers=data
    )

    return render_template('example.html',  mymap=mymap, sndmap=sndmap)
예제 #34
0
def simple_view_two():
    sndmap = Map(identifier="sndmap",
                 varname="sndmap",
                 lat=37.4419,
                 lng=-122.1419,
                 markers={
                     icons.dots.green: [(37.4419, -122.1419),
                                        (37.4500, -122.1350)],
                     icons.dots.blue: [(37.4300, -122.1400, "Hello World")]
                 })
    return jsonify(sndmap.as_json())
예제 #35
0
def mapview():

    food = get_items(FOOD)
    hygiene = get_items(HYGIENE)
    print(food)
    listoflists = []
    listoflists.append(food)
    listoflists.append(hygiene)

    # you must tell the variable 'form' what you named the class, above
    # 'form' is the variable name used in this template: index.html

    #form = NameForm()
    message = ""

    #form = RegisterNeed(request.form)
    #    if request.method == 'POST':
    #        flash('Working','success')

    #if form.validate_on_submit():
    #    print('test')

    # creating a map in the view
    mymap = Map(identifier="view-side",
                lat=53.5461,
                lng=-113.4938,
                markers=[(53.5461, -113.4938)])

    markers2 = []
    #list of markers
    for x in range(1, 20):
        lat1 = random.randrange(5346000, 5363000) / 100000
        lon1 = random.randrange(11342000, 11361000) / 100000
        lon1 = 0 - lon1
        print(lat1, lon1)
        markers2.append({
            'icon': 'http://maps.google.com/mapfiles/ms/icons/red-dot.png',
            #             'icon': 'http://www.entypo.com/images/hand.svg',
            #             'icon': 'bed.png',
            'lat': lat1,
            'lng': lon1,
            'infobox': MakePerson()
        })

    sndmap = Map(identifier="sndmap",
                 lat=53.5461,
                 lng=-113.4938,
                 style='height:600px;width:100%;margin:0;',
                 markers=markers2)

    return render_template('example.html',
                           mymap=mymap,
                           sndmap=sndmap,
                           listoflists=listoflists)
예제 #36
0
def mapview():
    mymap = Map(identifier="view-side",
                lat=37.4419,
                lng=-122.1419,
                markers=[(37.4419, -122.1419)])
    sndmap = Map(identifier="sndmap",
                 lat=37.4419,
                 lng=-122.1419,
                 markers={
                     icons.dots.green: [(37.4419, -122.1419),
                                        (37.4500, -122.1350)],
                     icons.dots.blue: [(37.4300, -122.1400, "Hello World")]
                 })

    trdmap = Map(identifier="trdmap",
                 lat=37.4419,
                 lng=-122.1419,
                 markers=[{
                     'icon':
                     icons.alpha.B,
                     'lat':
                     37.4419,
                     'lng':
                     -122.1419,
                     'infobox':
                     "Hello I am <b style='color:green;'>GREEN</b>!"
                 }, {
                     'icon':
                     icons.dots.blue,
                     'lat':
                     37.4300,
                     'lng':
                     -122.1400,
                     'infobox':
                     "Hello I am <b style='color:blue;'>BLUE</b>!"
                 }, {
                     'icon':
                     '//maps.google.com/mapfiles/ms/icons/yellow-dot.png',
                     'lat':
                     37.4500,
                     'lng':
                     -122.1350,
                     'infobox':
                     ("Hello I am <b style='color:#ffcc00;'>YELLOW</b>!"
                      "<h2>It is HTML title</h2>"
                      "<img src='//placehold.it/50'>"
                      "<br>Images allowed!")
                 }])

    return render_template('example.html',
                           mymap=mymap,
                           sndmap=sndmap,
                           trdmap=trdmap)
예제 #37
0
def polygon_view():
    polygon = {
        "stroke_color": "#0AB0DE",
        "stroke_opacity": 1.0,
        "stroke_weight": 3,
        "fill_color": "#ABC321",
        "fill_opacity": 0.5,
        "path": [
            {"lat": 33.678, "lng": -116.243},
            {"lat": 33.679, "lng": -116.244},
            {"lat": 33.680, "lng": -116.250},
            {"lat": 33.681, "lng": -116.239},
            {"lat": 33.678, "lng": -116.243},
        ],
    }

    path1 = [
        (33.665, -116.235),
        (33.666, -116.256),
        (33.667, -116.250),
        (33.668, -116.229),
    ]

    path2 = (
        (33.659, -116.243),
        (33.660, -116.244),
        (33.649, -116.250),
        (33.644, -116.239),
    )

    path3 = (
        [33.688, -116.243],
        [33.680, -116.244],
        [33.682, -116.250],
        [33.690, -116.239],
    )

    path4 = [
        [33.690, -116.243],
        [33.691, -116.244],
        [33.692, -116.250],
        [33.693, -116.239],
    ]

    pgonmap = Map(
        identifier="pgonmap",
        varname="pgonmap",
        lat=33.678,
        lng=-116.243,
        polygons=[polygon, path1, path2, path3, path4],
    )

    return jsonify(pgonmap.as_json())
예제 #38
0
def simple_view_two():
    sndmap = Map(
        identifier="sndmap",
        varname="sndmap",
        lat=37.4419,
        lng=-122.1419,
        markers={
            icons.dots.green: [(37.4419, -122.1419), (37.4500, -122.1350)],
            icons.dots.blue: [(37.4300, -122.1400, "Hello World")]
        }
    )
    return jsonify(sndmap.as_json())
예제 #39
0
def print_map():
    if request.method == 'POST':
        try:
            markers = parse_json(request.form['critterinos'], "database.json")
        except:
            raise
        try:
            lat = markers[0]['lat'] or 55.9444941
            lng = markers[0]['lng'] or -3.1863534
        except:
            lat = 55.9444941
            lng = -3.1863534
        mymap = Map(
            style=
            "height:1500%;width:150%;position: absolute; alignment:center; margin-top:6%;margin-left:-25%;",
            identifier="view-side",
            lat=lat,
            lng=lng,
            markers=markers,
            zoom=8,
            cluster=True,
            cluster_gridsize=10,
            maptype="TERRAIN")
        try:
            page = wikipedia.page(request.form['critterinos'])
            pagecontent = page.summary
            print(imagelink, pagecontent)
            return render_template('map.html',
                                   mymap=mymap,
                                   critters=["squirrels", "octopus", "frank"],
                                   pagecontent=pagecontent)
        except:
            return render_template('map.html',
                                   mymap=mymap,
                                   critters=["squirrels", "octopus", "frank"])

    if request.method == 'GET':
        markers = parse_json("", 'database.json')
        mymap = Map(
            style=
            "height:1500%;width:150%;position: absolute; alignment:center; margin-top:6%;margin-left:-25%;",
            identifier="view-side",
            lat=55.9444,
            lng=-3.1870,
            zoom=8,
            markers=markers,
            cluster=True,
            cluster_gridsize=10,
            maptype="TERRAIN")
        return render_template('map.html',
                               mymap=mymap,
                               critters=["squirrels", "octopus", "frank"])
def circle_view():
    circle = {
        "stroke_color": "#FF00FF",
        "stroke_opacity": 1.0,
        "stroke_weight": 7,
        "fill_color": "#FFFFFF",
        "fill_opacity": 0.8,
        "center": {"lat": 33.685, "lng": -116.251},
        "radius": 2000,
    }

    circlemap = Map(
        identifier="circlemap",
        varname="circlemap",
        lat=33.678,
        lng=-116.243,
        circles=[circle, [33.685, -116.251, 1000], (33.685, -116.251, 1500)],
    )

    return jsonify(circlemap.as_json())
예제 #41
0
def get_map():
    from app import conf
    config = conf()
    origin_lat = config.get('LAT')
    origin_lon = config.get('LON')
    key = get_google_map_api(config)
    fullmap = Map(
        identifier="fullmap2",
        style='height:100%;width:100%;top:0;left:0;position:absolute;z-index:200;',
        lat=origin_lat,
        lng=origin_lon,
        markers=get_pokemarkers(),
        zoom='20')
    fullmap_js = Markup(
            fullmap.render(
                    'googlemaps/gmapjs.html',
                    gmap=fullmap,
                    DEFAULT_ICON=DEFAULT_ICON,
                    GOOGLEMAPS_KEY=key
            )
    )
    return fullmap, fullmap_js