I want to find out list of all bus stops between two places using google map api.
I have all transit feeds , but i don't know how to work with that.
can anyone tell me the step by step process to work with google transit?
Thanks in advance..
There's a Google Transit official API, you can read about this here:
https://developers.google.com/maps/documentation/directions/#TravelModes
https://developers.google.com/maps/documentation/javascript/directions#TransitOptions
https://developers.google.com/maps/documentation/javascript/directions#TransitInformation
You must create a route for getting to this information:
directionsService.route({ 'origin': initial_pos, 'destination': final_pos, 'travelMode':google.maps.TravelMode.TRANSIT}, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
//Setting the map to display
directionsDisplay.setMap(map);
//Setting the direction panel
directionsDisplay.setPanel(document.getElementById("directionsPanel"));
//Setting the transit layer if you need
var transitLayer = new google.maps.TransitLayer();
transitLayer.setMap(map);
//Setting the directions response
directionsDisplay.setDirections(response);
});
Google transit is not a part of google maps API and has no api of itself.
You could add request param output=json to the end of google transit request link and parse json, or even try parsing HTML itself.
Related
How to obtain a city name from google map in ionic 2 If I have latitude and longitude coordinates of the area?
I searched all over the internet but I couldn't find the solution.
You can use Geociding, as explained in this thread from Ionic's forum
import { Geocoder, GeocoderRequest } from 'ionic-native';
let req: GeocoderRequest = { position: location }
Geocoder.geocode(req).then((results)=>{
})
You can find all you need about your location with this link. you can use geocode api as follow.
https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=YOUR_API_KEY
just replace latlng by those you have and key by your API key found on google console.
Reminder: To use the Geocoding API, you must include an API key with all API requests and you must enable billing on each of your projects
more infos here.
https://developers.google.com/maps/documentation/geolocation/intro
I used Google API to get data from google analytics, but the metrics not the same with the web interface of google analytics.
ie: I get data on 2015-03-01 - It return pageviews 79
But on web interface of google analytics, it is 80.
I had searched on some question the same me, but almost them show the way to solve is Sampling level.
I tried to set other Sampling level
DataResource.GaResource.GetRequest request = Service.Data.Ga.Get(profileId, startDate.ToString("yyyy-MM-dd"),
endDate.ToString("yyyy-MM-dd"), string.Join(",", metrics));
if (dimensions != null)
{
request.Dimensions = string.Join(",", dimensions);
}
request.SamplingLevel = DataResource.GaResource.GetRequest.SamplingLevelEnum.HIGHERPRECISION;
request.StartIndex = startIndex;
return request;
after that, the result return the same before, it not change.
So, anyone know this issue?
Simple its sampled data vs. unsampled data which you can read about here: https://support.google.com/analytics/answer/1042498?hl=en
For API work i normally use a web query explorer to verify that my API call's are being sent and responses match to verify the data: https://ga-dev-tools.appspot.com/explorer/
I have seen that it is possible with the "static" to limit the scope of the search to a certain area (with components restrictions), I have also seen that in release 3.exp (will be 3.14) of the JavaScript API, a new class google.maps.GeocoderComponentRestrictions has appeared. I have not seen anywhere how this class is supposed to be used though.
Does anyone have more information about this?
It looks like this was answered over at Google Maps Geocoding API, feature from the API missing in their JS api (?), with formatting like:
geocoder.geocode(
{ 'address': address, 'componentRestrictions':{'country':'GB'}},
function(results, status){
...
});
The GeocoderComponentRestrictions parameters get passed with the componentRestrictions key.
I'm developing a js single-page web application using a javascript client side mvc (angular.js in this case)
I added google analytic to the site, but from what I could see so far (at least in realtime) google doesn't take into account the part of the uri after the hash
that is I have a url like mydomain.com.ar/#/ideas/1 but for google analytics it looks just like mydomain.com.ar/
any idea?
You need to parse the parameters after # and send the data by using _trackPageview in order to see them on your pages report.
and here is how to do it,
var params = {},
queryString = location.hash.substring(1),
regex = /([^&=]+)=([^&]*)/g,
m;
while (m = regex.exec(queryString)) {
params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}
_gaq.push(['_trackPageview', queryString]);
Use $window dependency and call on route change.
Also use GA 'set' to ensure routes are picked up for Google realtime analytics.
$scope.$on('$routeChangeSuccess', function() {
$window.ga('set', 'page', $location.url());
$window.ga('send', 'pageview');
});
I am not using the v parm when I load the Google map API. Therefore I always get the "release" version of the API.
My app has an "About" feature and I would like to display the API version number.
Is there a way for me to get that value or would this be an enhancement request?
simply use: google.maps.version
http://jsfiddle.net/doktormolle/anN4U/
There was a way to get it from the filename of the script that loaded:
//*************************************************************
// API version from post on Google Maps API group by bratliff
var file,loop;
var tags=document.getElementsByTagName("SCRIPT");
// alert("tags="+tags.length);
for (loop=0;tags[loop];loop++)
{
if (file=tags[loop].src.match(/http:\/\/[^\&\?]+\.google\.[^\&\?]+\/([0-9]+)\/[^\&\?]+\/main\.js/)) {
//alert(file[1]);
document.getElementById("apiv").innerHTML = "API v2."+file[1];
}
}
//*************************************************************
You should be able to do the something similar for API v3.