The basic map of zhuhai is shown, nothing, only can prove normal rendering, no shortage of other so-called package
Again after a separation of graphic, do not display maps, also didn't find any reason,
There is no any error code section, there is show is fully illustrates the various aspects, API that has get through,
Ok, the following respectively the view code, urls, and HTML
The import json
The from the django. HTTP import JsonResponse
The from the django. Views the import the View
The from the django. Shortcuts import render
The from rest_framework. Views import APIView
The from pyecharts import options as opts
The from pyecharts. Faker import faker
The from pyecharts. Globals import ChartType
The from pyecharts. Charts import Geo
Def json_response (errno=200, errmsg="OK", data=https://bbs.csdn.net/topics/None, * * kwargs) :
Js_data={
https://bbs.csdn.net/topics/"Code" : errno,
"MSG" : errmsg,
"Data" : data
}
* * kwargs js_data. The update ()
Return JsonResponse (js_data)
The class Demo2View (View) :
"" "
Map test legend 2
Url:/map/demo2
"" "
Def get (self, request) :
Return render (request, "echarts/map. HTML")
The class Demo2ChartView (APIView) :
"" "
Map test legend 2 data loading page
Url:/map/demo2/chart
"" "
Def get (self, request) :
C=(
Geo ()
Add_schema (zhuhai, itemstyle_opts=opts. ItemStyleOpts (
Color="# 323 c48", border_color=Faker. Rand_color (), area_color="pink"))
. Add (" ", [the list (z) for z in zip ([" doumen district ", "golden bay area", "buy"], Faker. The values () [: 4])],
Type_=ChartType. EFFECT_SCATTER)
Set_series_opts (label_opts=opts. LabelOpts (is_show=False))
Set_global_opts (
Visualmap_opts=opts. VisualMapOpts (),
Title_opts=opts. TitleOpts (" zhuhai basic map ")
)
Dump_options_with_quotes ()
)
Return json_response (data=https://bbs.csdn.net/topics/json.loads (c))
Url
The from the django. Urls import path
From the import views
App_name="mapdemo"
Urlpatterns=[
Path (" demo2/", views. Demo2View. As_view (), name="demo2"),
Path (" demo2/chart/views. Demo2ChartView. As_view (), name="chart"),
]
<meta charset="utf-8" & gt;
<script SRC="https://cdn.bootcss.com/jquery/3.0.0/jquery.min.js" & gt; </script>
<body>
<script>
Var chart=echarts. Init (document. GetElementById () 'map', 'white' {the renderer: 'canvas'});
$(
The function () {
FetchData (chart);
}
);
The function fetchData () {
$. Ajax ({
Type: "GET",
Url: "/map/demo2/chart/",
DataType: 'json,
Success: the function (result) {
Chart. SetOption (result. The data);
}
});
}
</script>