在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):codeforgreenville/leaflet-google-sheets-template开源软件地址(OpenSource Url):https://github.com/codeforgreenville/leaflet-google-sheets-template开源编程语言(OpenSource Language):HTML 79.8%开源软件介绍(OpenSource Introduction):See https://data.openupstate.org/map-layers for existing open Greenville map layers and GeoJSON data. Why?Go to Google Maps, zoom into Greenville, SC and type "bike racks" or "dog parks". If you're lucky you get decent info, but inevitably you'll be looking at incomplete or irrelavant results. You may even get advertisments. This is not to say we should make a public-version of Google Map. Actually, we already have that in OpenStreetMaps. Rather, lots of great public infomation is locked inside all maps, proprietary and open maps alike, in much the same way styling was locked inside of HTML before CSS. The current lock-in approach reduces:
What's the Problem with Current Sharing Methods?Lets say you found park data on the city's GIS system and exported it out to a file. Now, you have the bright idea to build a Google Map with a layer for the parks, plus another layer for bathroom locations. You share it with friends and 5 of them love the idea. They make their own map with your city parks + their own interests (bike racks, breweries, dog parks, etc). Everyone goes about sharing and copying the layer data they like the most into their own personal maps. Cool, we have 6 interesting maps. One week later a dog park closes due to clown sightings. Spring comes and the city has a new park and 3 new breweries. Oh, and all the bike rakes were moved next to parking decks. Now what? Well, things get stale and maps die, that's what. How We Solve the Problem
Start With a New Google Spreadsheet
Publish Your Google Spreadsheet
Additions or changes to the spreadsheet will appear on a refreshed map somewhere between immediately and a few minutes later. You should plan on only having 1 tab in the spreadsheet. However, if for some reason you want to point at the data in the second tab within the spreadsheet then open that tab in you browser and look in the URL for gid=##########. You would need to append Allowing Other People to Help Curate the DataUse Google's Share function to give Edit permissions. You should consider allowing "Anyone with the link" to edit the data and then all you need to do is share the edit URL with trusted people. Using PHP to Convert a Google Sheets CSV to a GeoJSON FileThe "CSV data source URL" to be used in the geojson.php PHP script is the URL from the "File -> Publish to Web" step ex. Insert that URL in the $googleSpreadsheetUrl variable near the top of geojson.php file in your editor / workspace. The column values are used in this example to generate the GeoJSON are hard-coded to include 4 fields: longitude, latitude, title, and notes. If you need more columns / fields to your spreadsheet then you can add additional properties in your geojson.php under the You'd be best not to change order of the latitude and longitude columns in the spreadsheet. If you must change the order then you'd need to modify the corresponding code in geojson.php and index.html Getting Longitude and LatitudeNon-programming / manual ways to get latitude and longitude numbers
Rendering a Leaflet Map Showing the GeoJSON DataThe index.html is where you look to see the actual map. There is already a line of code to load the geojson.php into a Leaflet JS is using open MapQuest tiles. As of July 2016, it's necessary to register an account with MapQuest. Up to 15,000 views a month is free. Testing in Cloud 9
Registering for Map TilesThe base project includes a MapQuest key (key=bA5WISoAPsk5r0GJ3hHGTkAMFEskFOA2) in the index.html. Ideally you should register your own free account and use your own key to avoid exhausting this base key if too many people start using or abusing it. If using Mapquest then after registering for an account do the following:
If you register with CloudMade you can use their map tiles instead, as described by Leaflet example http://leafletjs.com/examples/geojson.html Multiple Layers and Advanced LeafletLeaflet has a bunch of other plug-ins and options, so the maps can be tweaked in all sorts of ways. Documentation for MapQuest and Leaflet Original concept from OpenData Day 2014 in Greenville SC |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论