How to consume GTFS feed in Google Map v3 using Javascript? - javascript

I'm first time trying to use GTFS(General Transit Feed Specification) with Google Maps as per the Google developers page i have understood the concept of .txt files which are used as feed and for making a demo i downloaded a transit zip files from Google developers page. but I'm not getting how to use those transit files to show information on map. I tried to search tutorial for the same but could not find anything useful. Do i need to parse all those files to show in map or there is something different implementation.
I'm confused.
Please bear me with my lack of knowledge regarding GTFS.

If you want to display stops and routes on a map, you can use gtfs-to-geojson to convert GTFS to GeoJSON that can be loaded onto a Google Map or Mapbox.
Install gtfs-to-geojson:
npm install gtfs-to-geojson -g
Setup a config.json file, then run:
gtfs-to-geojson --configPath /path/to/your/config.json
The tool will output a folder of GeoJSON files.

As far as I know, GTFS is not yet "plug and play" ready - there's no simple way to just load up a GTFS dataset and work with it or query it on Google Maps, using either Google's web interface or their Javascript libraries.
Getting this working requires:
Setting up a (SQL) database and importing the GTFS dataset into that database.
Setting up a query system to get the information you want out of the SQL database (e.g., a web front-end that queries the database backend).
Feel free to look at some examples from around the web:
Broader GTFS discussion, and a link to a PostgreSQL + R solution from James Wong
MongoDB + node.js from Brendan Nee

Related

Read Google App Script Files from another script

I am looking to create a little Google App Script to parse another GAS file to pull out the functions and any jsdoc type comments, and then display it.
Like if you navigate to a script you can get the revision history etc, but I wanted to be able to pass in a Drive folder containing multiple script files and develop a front end to display each's content.
I know about the Google Drive REST API with exportLinks do download as JSON.
I wondered if there was a simpler way to do it from another GAS file, or would I need to URLFetch of some description to do it over the RestAPI?
I have tried searching for similar things but they always lead back to the DriveAPI.
Any help with a starting place, or what GAS Objects I should start looking at?
Thank you
You have to use the REST based Drive API, there is really no other alternative. However, you don't need to use URLFetch to access it. Google Apps Script has what's known as Advance Google Services a collection of interfaces that grant native access to many REST based APIS including the Drive API.
You can check out the Drive specific documentation here. Its somewhat sparse, so you'll often have to fall back on the REST based documentation as well as rely on autocomplete inside the script editor to make sense of things.

Edit a google spreadsheet using javascript/client side code

I am new to google spreadsheets.
I am trying to use them for a small website where instead of maintaining a DB, I am storing and fetching data from sheets using APIs.
I found this library - https://github.com/mikeymckay/google-spreadsheet-javascript , for fetching data from a published sheet.
It serves my purpose of doing everything in the browser.
But I am not able to figure out how can I write data to same/different spreadsheet.
Do I use Sheet APIs? Can I also do it using App Script ? Is there a ready to use library for the same ?
Can someone please help?
You'd likely want to check out the Google Drive API, rather than Google Apps Scripts. I don't have much experience with it, especially in regards to using it on a website, but that's the best direction to head in.

Use shapefile as a web map?

I am wondering if it's possible to use a shapefile with point features in arcmap as a web map?
I have seen examples, however most of them project the shapefile on top of a base layer map, for example, Google maps or ESRI maps. I am purely wanting to use the shapefile as a web map that supports zoom? Is this possible? If so, how would I go about achieving this?
The only method I can think of so far is to save the shapefile as a service to arcGIS for server...
Any guidance and help will be very helpful.
Thanks in advance.
You could start off by importing the shapefile into TileMill. Once you have styled the layer, you could export it as an MBTile and serve it with Mapbox.
I also found this description that you might find helpful.
http://blog.thematicmapping.org/2012/11/exploring-mapbox-stack-mbtiles-tilejson.html
Good Luck.
If there aren't too many points (more than a few hundred) then you probably want to generate GeoJSON from the shapefile and display the data that way.
You can convert your shapefile to geojson with the GDAL library.
ogr2ogr -f GeoJSON -t_srs crs:84 [name].geojson [name].shp
If there are more than a few hundred points, then I'd use #andrewGeo's strategy.
The easier thing to do would be to share the shapefile from a server like ArcGIS Server or GeoServer. GeoServer tends to be easier to share something simple, especially if you use the Boundless Geo (http://boundlessgeo.com/). That comes with GeoExplorer which can directly consume a shapefile from GeoServer.
Depending on the API you're using to generate the basemap, you can hardcode x/y information into it or consume a KML/KMZ. These tend to be tedious and not great if you're doing more than just viewing static data.
If you choose the server option, beware about hosting and consuming your data on the same server. You may run into Cross Domain issues and life becomes a little more complex then. I believe GeoExplorer automatically bypassed any issues I had with Cross Domain, but most of the other JavaScript APIs were a little more troublesome.
With the release of QGIS 3.8 there is new feature to generate raster MBTiles layers. Once the layer you want to convert is setup, you can open up the Toolbox by either selecting the gear icon or by going into the processing tab on the menu bar and selecting toolbox. Then in the Processing Toolbox, drill-down into the Raster Tools section. Within this section, select the Generate XYZ tile (MBTiles) option. Then you can serve it into mapbox (currently GeoServer does support serving MBTiles as well by installing the MBTiles extension)
Here is a reference to this with a straight forward and well-illustrated example on how to use this new QGIS feature.

Generating redistributable map images without a server

I want to make an app that allows users to download static images of maps and redistribute them in Anki flashcard decks. However, I'm having a tough time figuring out how to generate the map images without facing any licencing restrictions or running my own server. I want my app to be all client side JavaScript which rules out one of the solutions I've found so far. I've seen a way to use openlayers to export images from the canvas, however a proxy sever is required to convert the canvas to a dataURL so it can be saved.
The most promising option I've found so far is the MapQuest Open Static Maps API. However, I can't find much information about how open it really is. The OSM data is open, but I'm not sure about the images themselves, as they say copyright mapquest on them. Mapbox also has a static map API with licensing restrictions that are unclear to me.
I ended up using leaflet-image. leaflet-image can generate image dataURLs from leafletjs L.map objects using OSM tiles. It uses CORS to request the tiles and avoid tainting the canvas.
Thanks to #tyr for mentioning leaflet-image in his comment. The issues I mentioned in the comments have been resolved.
We developed a solution using TileMill to generate MBTiles files. We then developed a very simple PHP script, which opened the MBTiles (essentially a sqlite db) then saved the blobs for each image out to a file.

Google APIs JS File

In building a Google Commerce Search search form, one of the pieces of code Google instructed us include was located at this address:
http://ajax.googleapis.com/ajax/libs/googleapis/0.0.4/googleapis.min.js
I'm getting a javascript error that seems to be emanating from this javascript file and I was wondering if this is the latest version of said javascript file? If not, can someone direct me as to where the latest version of this google api JS file lies?
P.S. I have been unable to get any conclusion from Google that this is the correct, most-up-to-date version of the file.
If you are looking after google search API - this is the location to find the latest:
https://developers.google.com/custom-search/v1/overview
In case you need some other APIs checkout their new location at:
https://developers.google.com/ you will have there a list of all the (many) APIs.

Categories