OpenTripPlanner with google API

358 views
Skip to first unread message

Judy Wang

unread,
Mar 13, 2015, 5:25:56 PM3/13/15
to opentripp...@googlegroups.com
Hi all,

I am a new programmer in Trip Planner area. I am learning how to use OTP for one of our projects. I found many documents talk about using OTP with Open Street Map (OSM). I have a question here, can OTP use google Map and google geocoder? If so, can anyone point me out how to use OTP with google Map?

Any help will be appreciated!

Thanks

Judy

Marko Burjek

unread,
Mar 15, 2015, 1:06:17 PM3/15/15
to OpenTripPlanner Developers
OTP uses Leaflet library for map tiles. According to its FAQ it is possible to use Google maps tiles with a plugin: https://github.com/Leaflet/Leaflet/blob/master/FAQ.md#i-want-to-use-google-maps-api-tiles-with-leaflet-can-i-do-that

I assume that this plugin is meant: https://github.com/shramov/leaflet-plugins/blob/master/layer/tile/Google.js

So to use Google map tiles you need to include this javascript file somewhere at the start of index.html after leaflet js is included: https://github.com/opentripplanner/OpenTripPlanner/blob/master/src/client/index.html#L33.

And then in config.js you need to remove all layers. And in core/map.js https://github.com/opentripplanner/OpenTripPlanner/blob/master/src/client/js/otp/core/Map.js you need to add google map tiles in this.baseLayers object.

Something like this this.baseLayers["streets"] = new L.Google('ROADMAP');
(other options are: SATELLITE, ROADMAP, HYBRID, TERRAIN
And it should work. But now that this proxies all request from Leaflet API to Google Maps api which means that map moving isn't so smooth anymore.

For using Google geocoder you can write own javascript class which uses this API: https://github.com/opentripplanner/OpenTripPlanner/blob/master/src/client/js/otp/core/Geocoder.js and supports Google Geocoder.
And then in config.js add it as module to geocoders.

Another option is to use GoogleGeocoder from server somehow:
Currently by default builtIn geocoder is used which is Lucene index of stops and other things in Graph, but there exists https://github.com/opentripplanner/OpenTripPlanner/blob/master/src/main/java/org/opentripplanner/geocoder/google/GoogleGeocoder.java class only I'm not sure how to use it.

--
You received this message because you are subscribed to the Google Groups "OpenTripPlanner Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opentripplanner...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages