In order to create a realtime transit layer, call the ShowTransitLayer method of the map object like this:
And yess, you got it. A realtime transit is plotted on the map. Just like that.
app.LoadPlugin("MapView"); function OnStart() { lay = app.CreateLayout("Linear", "VCenter, FillXY"); var apiKey = "AIzaSyD2eHntKEmh272p3ac6YjWPbPkwo3m2mck"; map = app.CreateMapView(apiKey, 0.9, 0.5, 7.0689323, 125.6114588, 13); map.SetOnReady(MapOnReady); lay.AddChild(map); btnShow = app.CreateButton("Show Transit"); btnShow.SetOnTouch(BtnOnTouch); btnShow.Hide(); lay.AddChild(btnShow); btnHide = app.CreateButton("Hide Transit"); btnHide.SetOnTouch(BtnOnTouch); btnHide.Hide(); lay.AddChild(btnHide); app.AddLayout(lay); } function MapOnReady() { btnShow.Show(); btnHide.Show(); } function BtnOnTouch() { if(this.GetText() == "Show Transit") { map.ShowTransitLayer(); } else { map.HideTransitLayer(); } }
ShowTransitLayer()
This will initialize an instance of the TransitLayer class and show the layer into the map.
HideTransitLayer()
This will hide the TransitLayer object in the map. This will not destroy object. Call the
ShowTransitLayer() method to show it again.
RemoveTransitLayer()
This will completely destroy TransitLayer object.