Long Nguyen
@longnguyenxuan
Viet Nam, Hanoi
Joined Oct 2017
World Rank: #31958 (0.8 points)
https://viblo.asia/p/nodejs-dung-selenium-cheerio-de-crawl-du-lieu-4dbZNDGq5YM /////////////////////////////////////////////////////////////////////// <!DOCTYPE html> <html> <head> <title>Simple Map</title> <meta name="viewport" content="initial-scale=1.0"> <meta charset="utf-8"> <style> /* Always set the map height explicitly to define the size of the div * element that contains the map. */ #map { height: 100%; } /* Optional: Makes the sample page fill the window. */ html, body { height: 100%; margin: 0; padding: 0; } </style> </head> <body> <div id="map"></div> <script src="MyScript.js"></script> <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBtvz3YOKjqxV3bolU5uY0UDruVfFNguS8" ></script> <script> var locations = [ ["Dai_Co_Viet", 21.008071, 105.847020, 3, 3.2, 230, "1.500.000 VND"], ["Giai_Phong", 21.004456, 105.841527, 5, 4.7, 290, "3.500.000 VND"], ["Nha nghi 1", 21.001772, 105.845132, 4, 4.1, 70, "2.000.000 VND"], ["Nha nghi 2", 21.005457, 105.847878, 2, 4.3, 90, "1.200.000 VND"] ]; var map; //-----------------------------------------------------------Khoi tao---------------------------------------------------------------// function initMap() { // map = new google.maps.Map(document.getElementById('map'), { // center: {lat: 21.024500, lng: 105.841170}, // zoom: 8 // }); map = new google.maps.Map(document.getElementById('map'), { zoom: 13, center: new google.maps.LatLng(21.024500, 105.841170), mapTypeId: google.maps.MapTypeId.ROADMAP }); var infowindow = new google.maps.InfoWindow(); var marker, i; var contentString = []; for (i = 0; i < locations.length; i++) { var numofstar = ""; for (var j = 0; j < locations[i][3]; j++){ numofstar += '\t\t<span class=\'fa fa-star checked\'></span>\n'; } contentString[i] = '<link rel=\'stylesheet\' href=\'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css\'>\n' + '\n' + '<style type=\'text/css\'>\n' + '\t.checked {\n' + '\t color: orange;\n' + '\t}\n' + '\t.uncheck{\n' + '\t\tcolor: green;\n' + '\t}\n' + '\t.wrapper {\n' + '\t display: inline-block;\n' + '\t padding: 5px;\n' + '\t border-radius: 3px;\n' + '\t font-family: Arial;\n' + '\t box-shadow: -1px 1px 3px #9a9a9a;\n' + '\t border-radius: 3px;\n' + '\t}\n' + '\t.hotel_photo {\n' + '\n' + '\t}\n' + '\t.hotel_name {\n' + '\t\tfont-size: 15px;\n' + '\t font-weight: bold;\n' + '\t margin: 10px 0;\n' + '\t}\n' + '\t.hotel_star {\n' + '\t\tfloat: left;\n' + '\t}\n' + '\t.hotel_review {\n' + '\t\tfloat: right;\n' + '\t}\n' + '\t.hotel_price {\n' + '\t\tcolor: red;\n' + '\t margin-top: 10px;\n' + '\t font-weight: bold;\n' + '\t font-size: 20px;\n' + '\t}\n' + '</style>\n' + '\n' + '<div class=\'wrapper\'>\n' + '\t<div class=\'hotel_photo\'>\n' + '\t\t<img style=\'max-width: 300px;\' src=\'img.jpg\'>\n' + '\t</div>\n' + '\t<div class=\'hotel_name\'>\n' + '\t\t' + locations[i][0] + '' + '\n' + '\t</div>\n' + '\t<div class=\'hotel_star\'>\n' + numofstar + '\t</div>\n' + '\t<div class=\'hotel_review\'>\n' + '\t\t' + locations[i][4] + '/5 (' + locations[i][5] + ')\n' + '\t</div>\n' + '\t<div style=\'clear: both\'></div>\n' + '\t<div class=\'hotel_price\'>' + locations[i][6] + '</div>\n' + '</div>'; var infowindow = new google.maps.InfoWindow({ //content: contentString.toString() }); marker = new google.maps.Marker({ position: new google.maps.LatLng(locations[i][1], locations[i][2]), map: map }); google.maps.event.addListener(marker, 'mouseover', (function(marker, i) { return function() { infowindow.setContent(contentString[i].toString()); infowindow.open(map, marker); } })(marker, i)); google.maps.event.addListener(marker, 'mouseout', (function(marker, i) { return function() { infowindow.close(); } })(marker, i)); } } //-----------------------------------------------------------Khoi tao---------------------------------------------------------------// //-----------------------------------------------------------Dinh vi---------------------------------------------------------------// function getLocation(){ infoWindow = new google.maps.InfoWindow; // Try HTML5 geolocation. if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var pos = { lat: position.coords.latitude, lng: position.coords.longitude }; infoWindow.setPosition(pos); infoWindow.setContent('Location found.'); infoWindow.open(map); map.setCenter(pos); }, function() { handleLocationError(true, infoWindow, map.getCenter()); }); } else { //Trình duyệt không hỗ trợ Location handleLocationError(false, infoWindow, map.getCenter()); } function handleLocationError(browserHasGeolocation, infoWindow, pos) { infoWindow.setPosition(pos); infoWindow.setContent(browserHasGeolocation ? 'Error: The Geolocation service failed.' : 'Error: Your browser doesn\'t support geolocation.'); infoWindow.open(map); } } //-----------------------------------------------------------Dinh vi---------------------------------------------------------------// google.maps.event.addDomListener(window, 'load', initMap); google.maps.event.addDomListener(window, 'load', getLocation); </script> </body> </html> https://github.com/johntitus/node-horseman#waitforselectorselector https://github.com/hoangnl/MobileShopping
Activity over the last year
Effectiveness
- Problems solved
- 16
- Solutions submitted
- 139