Advertisement
vitareinforce

leaflet sample api

Aug 15th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let map = L.map('map').setView([-6.888185, 107.610022 ], 18);
  2.  
  3. let xhr = new XMLHttpRequest();
  4. xhr.open('GET', 'data.geojson'); //sementara gini dulu karena cors mu msh error, ntar si data.geojson ganti make url api mu
  5. xhr.setRequestHeader('Content-Type', 'application/json');
  6. xhr.onload = function() {
  7.     if (xhr.status === 200) {
  8.         L.geoJSON(JSON.parse(xhr.responseText), {
  9.             style: {
  10.                 "color": "#ff7800",
  11.                 "weight": 5,
  12.                 "opacity": 0.65
  13.             },
  14.             }).addTo(map);
  15.     }
  16. };
  17. xhr.send();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement