当前位置:   article > 正文

用Django+Json对百度地图进行标点(项目)可将经纬度转化为地址_django 国内地址地图 免费地图插件

django 国内地址地图 免费地图插件

1、先绘制一张中国大地图:可展示中国大致的疫情情况

2、大地图可跳转至各个省份

3、当大地图跳转至重庆,进入百度地图

4、对【小镭】经过的点进行标记

点击省份【四川】,可进入四川省份地图,双击退回全国地图

 点击省份【重庆】,输入要查询的姓名 ,如【小镭】,提交后进入百度地图

可查看到【小镭】经过了两个地点(坐标),并在百度地图上显示

 划过跳动的标记点,可查看详细信息

 

思路:

用户在前端输入要查询的数据,表单提交到后台,后台进行判断,如果传过来的数据能匹配到后台列表里的【姓名】,则返回对应的姓名的【坐标列表】,若没有则返回【查询不到信息】。

(1)配置URL

  1. from django.conf.urls import url
  2. from demo import views
  3. from django.urls import path
  4. urlpatterns = [
  5. url(r'^T/$', views.home, name='demo'),
  6. ]

(2)定义视图函数

获取前端表单提交的数据,后台对传过来的姓名进行搜索,再将对应的坐标数据传给前端

  1. def home(request):
  2. Dict0 = {'小甲':[(106.584766,29.568199),
  3. (107.790934,29.376906),
  4. (109.894762,31.086327),
  5. (108.779749,29.305089),
  6. (106.628838,29.561727),
  7. (106.450859,29.495614),
  8. (106.439876,29.591537)],
  9. '小乙':[(108.758913,28.864319),
  10. (106.397459,28.622101),
  11. (106.521106,29.672908),
  12. (107.745381,29.503326),
  13. (107.915022,29.235099),
  14. (107.811703,29.439361),
  15. (107.732167,29.892034),
  16. (106.44153,29.590758)],
  17. '小丙':[(106.543065,29.555566),
  18. (105.801354,29.754546),
  19. (106.583661,29.563793),
  20. (106.590326,29.722571),
  21. (106.516083,29.633519),
  22. (106.548765,29.496741),
  23. (106.583541,29.563475),],
  24. '小丁':[(106.438521,29.582918),
  25. (106.689189,29.612501),
  26. (106.514014,29.575783),
  27. (106.599318,29.514712),
  28. (106.594374,29.572838),
  29. (106.494897,29.607112),
  30. (106.207561,29.562208),
  31. (106.546513,29.557545),],
  32. '小镭':[
  33. (106.513084,29.621921),
  34. (106.31856,29.520634),
  35. (108.221158,29.190937),
  36. (106.83719,29.864257),
  37. (106.556125,29.69365),
  38. (106.555731,29.687757),
  39. (106.557197,29.682198),
  40. (106.841025,29.865025),
  41. (106.563211,29.68192),],
  42. '小黑':[(106.315249,29.613585),
  43. (106.544191,29.558955),
  44. (106.512695,29.381705),
  45. (106.462002,29.5383),
  46. (106.556521,29.618368),]
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/498407
推荐阅读
相关标签
  

闽ICP备14008679号