質問編集履歴
2
ソースコード、エラー文の記述を致しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,7 +18,13 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
+
Lhankor_Mhy様に回答を頂いた後、該当ソースコードを変更→その後発生したエラー
|
22
|
+
|
23
|
+
Error: Invalid LatLng object: (35.0155833957335, NaN)
|
24
|
+
|
21
25
|
### 該当のソースコード
|
26
|
+
|
27
|
+
Lhankor_Mhy様に回答していただき、ソースコードを調整いたしました。
|
22
28
|
|
23
29
|
```views_models.py(geojsonを形成しているpythonファイル)
|
24
30
|
|
@@ -54,31 +60,39 @@
|
|
54
60
|
|
55
61
|
return {
|
56
62
|
|
57
|
-
|
63
|
+
"type": "FeatureCollection",
|
58
64
|
|
59
|
-
|
65
|
+
"features": [
|
60
66
|
|
61
|
-
|
67
|
+
{
|
62
68
|
|
69
|
+
"type": "Feature",
|
70
|
+
|
71
|
+
"properties": {
|
72
|
+
|
73
|
+
'node': {
|
74
|
+
|
63
|
-
'node_id': node1.node_id,
|
75
|
+
'node_id': node1.node_id,
|
76
|
+
|
77
|
+
},
|
78
|
+
|
79
|
+
'popupContent': 'これは'+ str(node1.node_id) + '番目です。',
|
80
|
+
|
81
|
+
"distance": qick_distance(node1.latlng.x,node1.latlng.y,node2.latlng.x,node2.latlng.y),
|
82
|
+
|
83
|
+
},
|
84
|
+
|
85
|
+
"geometry": {
|
86
|
+
|
87
|
+
"type": "Point",
|
88
|
+
|
89
|
+
"coordinates": [node1.latlng.x,node1.latlng.y],
|
90
|
+
|
91
|
+
},
|
64
92
|
|
65
93
|
},
|
66
94
|
|
67
|
-
'popupContent': 'これは'+ str(node1.node_id) + '番目です。',
|
68
|
-
|
69
|
-
'distance':qick_distance(node1.latlng.x,node1.latlng.y,node2.latlng.x,node2.latlng.y),
|
70
|
-
|
71
|
-
},
|
72
|
-
|
73
|
-
'geometry': {
|
74
|
-
|
75
|
-
'type': 'Point',
|
76
|
-
|
77
|
-
'coordinates': [node1.latlng.x,node1.latlng.y],
|
78
|
-
|
79
|
-
},
|
80
|
-
|
81
|
-
}
|
95
|
+
]}
|
82
96
|
|
83
97
|
```
|
84
98
|
|
@@ -88,7 +102,7 @@
|
|
88
102
|
|
89
103
|
var Marker = function(feature, latlng) {
|
90
104
|
|
91
|
-
return new L.Circle
|
105
|
+
return new L.Circle(latlng, {
|
92
106
|
|
93
107
|
radius: 3,
|
94
108
|
|
1
ソースコードについて、変更いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,9 +20,71 @@
|
|
20
20
|
|
21
21
|
### 該当のソースコード
|
22
22
|
|
23
|
+
```views_models.py(geojsonを形成しているpythonファイル)
|
23
24
|
|
25
|
+
from math import cos, sqrt
|
24
26
|
|
27
|
+
import numpy as np
|
28
|
+
|
29
|
+
class NodeLatlngMapper:
|
30
|
+
|
31
|
+
"""ノードマッパー"""
|
32
|
+
|
33
|
+
def as_dict(self, node1, node2):
|
34
|
+
|
35
|
+
def qick_distance(Lat1, Long1, Lat2, Long2):
|
36
|
+
|
37
|
+
#degreeからradianへ
|
38
|
+
|
39
|
+
Lat1 = np.deg2rad(Lat1)
|
40
|
+
|
41
|
+
Lat2 = np.deg2rad(Lat2)
|
42
|
+
|
43
|
+
Long1 = np.deg2rad(Long1)
|
44
|
+
|
45
|
+
Long2 = np.deg2rad(Long2)
|
46
|
+
|
47
|
+
x = Lat2 - Lat1
|
48
|
+
|
49
|
+
y = (Long2 - Long1) * cos((Lat2 + Lat1)*0.00872664626)
|
50
|
+
|
51
|
+
#戻り地はm
|
52
|
+
|
53
|
+
return 111.138 * sqrt(x*x + y*y) * 1000
|
54
|
+
|
55
|
+
return {
|
56
|
+
|
57
|
+
'type': 'Feature',
|
58
|
+
|
59
|
+
'properties': {
|
60
|
+
|
61
|
+
'node': {
|
62
|
+
|
63
|
+
'node_id': node1.node_id,
|
64
|
+
|
65
|
+
},
|
66
|
+
|
67
|
+
'popupContent': 'これは'+ str(node1.node_id) + '番目です。',
|
68
|
+
|
69
|
+
'distance':qick_distance(node1.latlng.x,node1.latlng.y,node2.latlng.x,node2.latlng.y),
|
70
|
+
|
71
|
+
},
|
72
|
+
|
73
|
+
'geometry': {
|
74
|
+
|
75
|
+
'type': 'Point',
|
76
|
+
|
77
|
+
'coordinates': [node1.latlng.x,node1.latlng.y],
|
78
|
+
|
79
|
+
},
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
```
|
84
|
+
|
25
|
-
```
|
85
|
+
```canvas.jsの一部
|
86
|
+
|
87
|
+
V.showNodesLayer = function(geojson) {
|
26
88
|
|
27
89
|
var Marker = function(feature, latlng) {
|
28
90
|
|
@@ -39,6 +101,26 @@
|
|
39
101
|
})
|
40
102
|
|
41
103
|
};
|
104
|
+
|
105
|
+
L.geoJson(geojson, {pointToLayer: Marker},).addTo(map).on( 'click', function(e) { clickEvt(e); });
|
106
|
+
|
107
|
+
function onEachFeature(feature, layer) {
|
108
|
+
|
109
|
+
if (feature.properties && feature.properties.popupContent) {
|
110
|
+
|
111
|
+
layer.bindPopup(feature.properties.popupContent);
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
function clickEvt(e){
|
118
|
+
|
119
|
+
alert('HelloWorld');
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
}
|
42
124
|
|
43
125
|
```
|
44
126
|
|