Difference between revisions of "Test"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
<html> | <html> | ||
− | <head> | + | <head> |
− | <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" /> | + | <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" /> |
− | + | <script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> | <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> | ||
− | + | <style> | |
− | <style> | + | #map { |
− | #map { | + | height: 500px; |
− | + | width: 100%; | |
− | + | max-width: 100%; | |
− | + | max-height: 100%; | |
− | + | } | |
− | } | + | </style> |
− | </style> | + | </head> |
− | + | <body> | |
− | + | <div id="map" style="width: 100%; height: 500px;"></div> | |
− | </head> | + | |
− | + | <script> | |
− | + | var url = 'REFUGIA_MALEY96.geojson'; // my GeoJSON data source, in same folder as my html page. | |
− | |||
− | <script> | ||
− | var url = 'REFUGIA_MALEY96.geojson'; // my GeoJSON data source, in same folder as my html page. | ||
var map = L.map('map').setView([47.7541, -107.05078], 3); | var map = L.map('map').setView([47.7541, -107.05078], 3); | ||
Line 28: | Line 25: | ||
var osm=new L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png',{ | var osm=new L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png',{ | ||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}).addTo(map); | attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}).addTo(map); | ||
− | + | ||
− | + | function style(feature) { | |
− | |||
− | function style(feature) { | ||
return { | return { | ||
fillColor: 'green', | fillColor: 'green', | ||
Line 41: | Line 36: | ||
}; | }; | ||
} | } | ||
− | + | var url = 'BaseBallFinal.json'; | |
− | + | var bbTeam = L.geoJSON(null, {onEachFeature: forEachFeature, style: style}); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | var | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | // Get GeoJSON data and create features. | |
− | + | $.getJSON(url, function(data) { | |
− | + | bbTeam.addData(data); | |
− | + | }); | |
− | // | ||
− | |||
− | </script> </body> | + | bbTeam.addTo(map); |
+ | </script> | ||
+ | </body> | ||
</html> | </html> |
Revision as of 09:24, 25 February 2022