赞
踩
1、先绘制一张中国大地图:可展示中国大致的疫情情况
2、大地图可跳转至各个省份
3、当大地图跳转至重庆,进入百度地图
4、对【小镭】经过的点进行标记
点击省份【四川】,可进入四川省份地图,双击退回全国地图
点击省份【重庆】,输入要查询的姓名 ,如【小镭】,提交后进入百度地图
可查看到【小镭】经过了两个地点(坐标),并在百度地图上显示
划过跳动的标记点,可查看详细信息
思路:
用户在前端输入要查询的数据,表单提交到后台,后台进行判断,如果传过来的数据能匹配到后台列表里的【姓名】,则返回对应的姓名的【坐标列表】,若没有则返回【查询不到信息】。
(1)配置URL
- from django.conf.urls import url
- from demo import views
- from django.urls import path
-
- urlpatterns = [
- url(r'^T/$', views.home, name='demo'),
- ]
(2)定义视图函数
获取前端表单提交的数据,后台对传过来的姓名进行搜索,再将对应的坐标数据传给前端
-
- def home(request):
- Dict0 = {'小甲':[(106.584766,29.568199),
- (107.790934,29.376906),
- (109.894762,31.086327),
- (108.779749,29.305089),
- (106.628838,29.561727),
- (106.450859,29.495614),
- (106.439876,29.591537)],
- '小乙':[(108.758913,28.864319),
- (106.397459,28.622101),
- (106.521106,29.672908),
- (107.745381,29.503326),
- (107.915022,29.235099),
- (107.811703,29.439361),
- (107.732167,29.892034),
- (106.44153,29.590758)],
- '小丙':[(106.543065,29.555566),
- (105.801354,29.754546),
- (106.583661,29.563793),
- (106.590326,29.722571),
- (106.516083,29.633519),
- (106.548765,29.496741),
- (106.583541,29.563475),],
- '小丁':[(106.438521,29.582918),
- (106.689189,29.612501),
- (106.514014,29.575783),
- (106.599318,29.514712),
- (106.594374,29.572838),
- (106.494897,29.607112),
- (106.207561,29.562208),
- (106.546513,29.557545),],
- '小镭':[
- (106.513084,29.621921),
- (106.31856,29.520634),
- (108.221158,29.190937),
- (106.83719,29.864257),
- (106.556125,29.69365),
- (106.555731,29.687757),
- (106.557197,29.682198),
- (106.841025,29.865025),
- (106.563211,29.68192),],
- '小黑':[(106.315249,29.613585),
- (106.544191,29.558955),
- (106.512695,29.381705),
- (106.462002,29.5383),
- (106.556521,29.618368),]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。