7
7
*/
8
8
9
9
10
+
10
11
function addMarkerToGroup ( group , coordinate , html ) {
11
12
var marker = new H . map . Marker ( coordinate ) ;
12
13
// add custom data to the marker
@@ -17,7 +18,6 @@ function addMarkerToGroup(group, coordinate, html) {
17
18
18
19
function getnews ( city ) {
19
20
var obj ;
20
- // var url = "https://newsapi.org/v2/top-headlines?country=jp&apiKey=7b5f48dbc9e348db8616f70b532aff14";
21
21
var url = 'https://newsapi.org/v2/top-headlines?' +
22
22
'q=' + city + '&' +
23
23
'sortBy=popularity&' +
@@ -27,9 +27,21 @@ function getnews(city){
27
27
. then ( ( response ) => response . json ( ) )
28
28
. then ( ( responseJSON ) => {
29
29
let newRes = responseJSON ;
30
-
31
- alert ( newRes . articles [ 0 ] . title , newRes . articles [ 0 ] )
32
- } )
30
+ swal ( {
31
+ title : newRes . articles [ 0 ] . title ,
32
+ text : newRes . articles [ 0 ] . content ,
33
+ icon : "info" ,
34
+ buttons : [ true , "See Full Article" ] ,
35
+ } ) . then ( okay => {
36
+ if ( okay ) {
37
+ window . location . href = newRes . articles [ 0 ] . url ;
38
+ }
39
+ } ) ;
40
+ } ) . catch ( swal ( {
41
+ title : "Error" ,
42
+ text : "No News at the moment. Try again later." ,
43
+ icon : "warning"
44
+ } ) )
33
45
}
34
46
35
47
// initialize communication with the platform
@@ -44,8 +56,8 @@ var defaultLayers = platform.createDefaultLayers();
44
56
// initialize a map - this map is centered over Europe
45
57
var map = new H . Map ( document . getElementById ( 'map1' ) ,
46
58
defaultLayers . normal . map , {
47
- center : { lat : 53.430 , lng : - 2.961 } ,
48
- zoom : 4
59
+ center : { lat : 0 , lng : 0 } ,
60
+ zoom : 2
49
61
} ) ;
50
62
51
63
// MapEvents enables the event system
@@ -120,7 +132,35 @@ addInfoBubble(map);
120
132
addMarkerToGroup ( group , { lat :- 33.8688 , lng :151.2093 } ,
121
133
`<button onclick="getnews(\'Sydney\')">Sydney</button>` ) ;
122
134
123
-
135
+ addMarkerToGroup ( group , { lat :- 30.559483 , lng :22.937506 } ,
136
+ `<button onclick="getnews(\'South Africa\')">South Africa</button>` ) ;
137
+
138
+ addMarkerToGroup ( group , { lat :- 35.675148 , lng :- 71.542969 } ,
139
+ `<button onclick="getnews(\'Chile\')">Chile</button>` ) ;
140
+
141
+ addMarkerToGroup ( group , { lat :- 14.235004 , lng :- 51.925282 } ,
142
+ `<button onclick="getnews(\'Brasil\')">Brasil</button>` ) ;
143
+
144
+ addMarkerToGroup ( group , { lat :45.501690 , lng :- 73.567253 } ,
145
+ `<button onclick="getnews(\'Montreal\')">Montreal</button>` ) ;
146
+
147
+ addMarkerToGroup ( group , { lat :59.938480 , lng :30.312481 } ,
148
+ `<button onclick="getnews(\'Saint Petersbourg\')">Saint Petersbourg</button>` ) ;
149
+
150
+ addMarkerToGroup ( group , { lat :53.349804 , lng :- 6.260310 } ,
151
+ `<button onclick="getnews(\'Dublin\')">Dublin</button>` ) ;
152
+
153
+ addMarkerToGroup ( group , { lat :9.081999 , lng :8.675277 } ,
154
+ `<button onclick="getnews(\'Nigeria\')">Nigeria</button>` ) ;
155
+
156
+ addMarkerToGroup ( group , { lat :41.299496 , lng :69.240074 } ,
157
+ `<button onclick="getnews(\'Tashkent\')">Tashkent</button>` ) ;
158
+
159
+ addMarkerToGroup ( group , { lat :47.606209 , lng :- 122.332069 } ,
160
+ `<button onclick="getnews(\'Seattle\')">Seattle</button>` ) ;
161
+
162
+ addMarkerToGroup ( group , { lat :37.774929 , lng :- 122.419418 } ,
163
+ `<button onclick="getnews(\'San Francisco\')">San Francisco</button>` ) ;
124
164
}
125
165
126
166
// initialize communication with the platform
@@ -135,7 +175,7 @@ addInfoBubble(map);
135
175
// initialize a map - this map is centered over Europe
136
176
var map = new H . Map ( document . getElementById ( 'map' ) ,
137
177
defaultLayers . normal . map , {
138
- center : { lat : 53.430 , lng : - 2.961 } ,
178
+ center : { lat : 0 , lng : 0 } ,
139
179
zoom : 7
140
180
} ) ;
141
181
0 commit comments