ওভারভিউ
এই টিউটোরিয়ালটি আপনাকে দেখায় কিভাবে Google মানচিত্রে ডেটা ভিজ্যুয়ালাইজ করতে হয়। উদাহরণ হিসাবে, এই টিউটোরিয়ালের মানচিত্রগুলি ভূমিকম্পের অবস্থান এবং মাত্রা সম্পর্কে ডেটা কল্পনা করে। আপনার নিজস্ব ডেটা উত্সের সাথে ব্যবহার করার কৌশলগুলি শিখুন এবং নীচের মত Google মানচিত্রে শক্তিশালী গল্প তৈরি করুন৷
বাম দিকের ফ্রেমটি মৌলিক মার্কার সহ একটি মানচিত্র প্রদর্শন করে এবং ডানদিকের ফ্রেমটি আকারের বৃত্ত সহ একটি মানচিত্র প্রদর্শন করে৷
আপনার ডেটা আমদানি করুন
এই টিউটোরিয়ালটি ইউনাইটেড স্টেটস জিওলজিক্যাল সার্ভে (USGS) থেকে রিয়েল-টাইম ভূমিকম্প ডেটা ব্যবহার করে। ইউএসজিএস ওয়েবসাইটটি বেশ কয়েকটি ফর্ম্যাটে তাদের ডেটা সরবরাহ করে, যা আপনি আপনার অ্যাপ্লিকেশনের মাধ্যমে স্থানীয় অ্যাক্সেসের জন্য আপনার ডোমেনে অনুলিপি করতে পারেন। এই টিউটোরিয়ালটি নথির মাথায় একটি script
ট্যাগ যুক্ত করে সরাসরি USGS সার্ভার থেকে JSONP-কে অনুরোধ করে।
// Create a script tag and set the USGS URL as the source. var script = document.createElement('script'); script.src = 'http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.geojsonp'; document.getElementsByTagName('head')[0].appendChild(script);
মৌলিক মার্কার রাখুন
এখন আপনি ইউএসজিএস ফিড থেকে ভূমিকম্পের অবস্থান সম্পর্কে ডেটা আপনার অ্যাপ্লিকেশনে টেনেছেন, আপনি এটি মানচিত্রে প্রদর্শন করতে পারেন। এই বিভাগটি আপনাকে দেখায় কিভাবে একটি মানচিত্র তৈরি করতে হয় যা প্রতিটি ভূমিকম্পের কেন্দ্রস্থলে একটি মৌলিক মার্কার স্থাপন করতে আমদানি করা ডেটা ব্যবহার করে।
নীচের বিভাগটি এই টিউটোরিয়ালে মানচিত্র তৈরি করার জন্য আপনার প্রয়োজনীয় পুরো কোডটি প্রদর্শন করে।
টাইপস্ক্রিপ্ট
let map: google.maps.Map; function initMap(): void { map = new google.maps.Map(document.getElementById("map") as HTMLElement, { zoom: 2, center: new google.maps.LatLng(2.8, -187.3), mapTypeId: "terrain", }); // Create a <script> tag and set the USGS URL as the source. const script = document.createElement("script"); // This example uses a local copy of the GeoJSON stored at // http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.geojsonp script.src = "https://developers.google.com/maps/documentation/javascript/examples/json/earthquake_GeoJSONP.js"; document.getElementsByTagName("head")[0].appendChild(script); } // Loop through the results array and place a marker for each // set of coordinates. const eqfeed_callback = function (results: any) { for (let i = 0; i < results.features.length; i++) { const coords = results.features[i].geometry.coordinates; const latLng = new google.maps.LatLng(coords[1], coords[0]); new google.maps.Marker({ position: latLng, map: map, }); } }; declare global { interface Window { initMap: () => void; eqfeed_callback: (results: any) => void; } } window.initMap = initMap; window.eqfeed_callback = eqfeed_callback;
জাভাস্ক্রিপ্ট
let map; function initMap() { map = new google.maps.Map(document.getElementById("map"), { zoom: 2, center: new google.maps.LatLng(2.8, -187.3), mapTypeId: "terrain", }); // Create a <script> tag and set the USGS URL as the source. const script = document.createElement("script"); // This example uses a local copy of the GeoJSON stored at // http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.geojsonp script.src = "https://developers.google.com/maps/documentation/javascript/examples/json/earthquake_GeoJSONP.js"; document.getElementsByTagName("head")[0].appendChild(script); } // Loop through the results array and place a marker for each // set of coordinates. const eqfeed_callback = function (results) { for (let i = 0; i < results.features.length; i++) { const coords = results.features[i].geometry.coordinates; const latLng = new google.maps.LatLng(coords[1], coords[0]); new google.maps.Marker({ position: latLng, map: map, }); } }; window.initMap = initMap; window.eqfeed_callback = eqfeed_callback;
সিএসএস
/* * 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; }
এইচটিএমএল
<html> <head> <title>Earthquake Markers</title> <link rel="stylesheet" type="text/css" href="./style.css" /> <script type="module" src="./index.js"></script> </head> <body> <div id="map"></div> <!-- The `defer` attribute causes the script to execute after the full HTML document has been parsed. For non-blocking uses, avoiding race conditions, and consistent behavior across browsers, consider loading using Promises. See https://developers.google.com/maps/documentation/javascript/load-maps-js-api for more information. --> <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB41DRUbKWJHPxaFjMAwdrzWzbVKartNGg&callback=initMap&v=weekly" defer ></script> </body> </html>
নমুনা চেষ্টা করুন
মানচিত্র কাস্টমাইজ করতে আকার ব্যবহার করুন
এই বিভাগটি আপনাকে মানচিত্রে সমৃদ্ধ ডেটাসেটগুলি কাস্টমাইজ করার আরেকটি উপায় দেখায়। এই টিউটোরিয়ালের পূর্ববর্তী বিভাগে তৈরি করা মানচিত্রটি বিবেচনা করুন, যা প্রতিটি ভূমিকম্পের অবস্থানে মার্কার দেখায়। আপনি অতিরিক্ত ডেটা কল্পনা করতে মার্কারগুলি কাস্টমাইজ করতে পারেন, যেমন মাত্রা বা গভীরতা।
নিচের মানচিত্রটি বৃত্ত প্রতীক আইকন ব্যবহার করে কাস্টমাইজড মার্কার প্রদর্শন করে। প্রতিটি বৃত্তের আকার ভূমিকম্পের মাত্রার সাথে বৃদ্ধি পায় যা এটি প্রতিনিধিত্ব করে।
নীচের বিভাগটি কাস্টমাইজড চেনাশোনা মার্কারগুলির সাথে একটি মানচিত্র তৈরি করতে আপনার প্রয়োজনীয় পুরো কোডটি প্রদর্শন করে৷
টাইপস্ক্রিপ্ট
let map: google.maps.Map; function initMap(): void { map = new google.maps.Map(document.getElementById("map") as HTMLElement, { zoom: 2, center: { lat: -33.865427, lng: 151.196123 }, mapTypeId: "terrain", }); // Create a <script> tag and set the USGS URL as the source. const script = document.createElement("script"); // This example uses a local copy of the GeoJSON stored at // http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.geojsonp script.src = "https://developers.google.com/maps/documentation/javascript/examples/json/earthquake_GeoJSONP.js"; document.getElementsByTagName("head")[0].appendChild(script); map.data.setStyle((feature) => { const magnitude = feature.getProperty("mag") as number; return { icon: getCircle(magnitude), }; }); } function getCircle(magnitude: number) { return { path: google.maps.SymbolPath.CIRCLE, fillColor: "red", fillOpacity: 0.2, scale: Math.pow(2, magnitude) / 2, strokeColor: "white", strokeWeight: 0.5, }; } function eqfeed_callback(results: any) { map.data.addGeoJson(results); } declare global { interface Window { initMap: () => void; eqfeed_callback: (results: any) => void; } } window.initMap = initMap; window.eqfeed_callback = eqfeed_callback;
জাভাস্ক্রিপ্ট
let map; function initMap() { map = new google.maps.Map(document.getElementById("map"), { zoom: 2, center: { lat: -33.865427, lng: 151.196123 }, mapTypeId: "terrain", }); // Create a <script> tag and set the USGS URL as the source. const script = document.createElement("script"); // This example uses a local copy of the GeoJSON stored at // http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.geojsonp script.src = "https://developers.google.com/maps/documentation/javascript/examples/json/earthquake_GeoJSONP.js"; document.getElementsByTagName("head")[0].appendChild(script); map.data.setStyle((feature) => { const magnitude = feature.getProperty("mag"); return { icon: getCircle(magnitude), }; }); } function getCircle(magnitude) { return { path: google.maps.SymbolPath.CIRCLE, fillColor: "red", fillOpacity: 0.2, scale: Math.pow(2, magnitude) / 2, strokeColor: "white", strokeWeight: 0.5, }; } function eqfeed_callback(results) { map.data.addGeoJson(results); } window.initMap = initMap; window.eqfeed_callback = eqfeed_callback;
সিএসএস
/* * 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; }
এইচটিএমএল
<html> <head> <title>Earthquake Circles</title> <link rel="stylesheet" type="text/css" href="./style.css" /> <script type="module" src="./index.js"></script> </head> <body> <div id="map"></div> <!-- The `defer` attribute causes the script to execute after the full HTML document has been parsed. For non-blocking uses, avoiding race conditions, and consistent behavior across browsers, consider loading using Promises. See https://developers.google.com/maps/documentation/javascript/load-maps-js-api for more information. --> <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB41DRUbKWJHPxaFjMAwdrzWzbVKartNGg&callback=initMap&v=weekly" defer ></script> </body> </html>
নমুনা চেষ্টা করুন
আরও তথ্য
নিম্নলিখিত বিষয়গুলি সম্পর্কে আরও পড়ুন: