I've been messing around with Google Maps API. It returns a position object, with relevant bit being the following:
{
"speed": 1.41837963
}
I have a number of readings from driving around the block ranging from -1, 0 (understandable since I was just sitting there) to about 19~. It seems about right considering how I was driving but how does this translate into approximate mph?
I'm assuming your not using Google Maps to obtain the user's position, but instead using the W3C Geolocation standard. Speed is given in meters/second, so to convert to MPH just multiply the returned value by 2.23694.
If your code contains something like navigator.geolocation.getCurrentPosition() or navigator.geolocation.watchPosition(), then speed is given in m/s. If, however, the above methods don't look familiar, post your code, or the endpoint you're requesting and I'd be more than happy to try to get you sorted out.
I was unable to find any documentation on google maps api position object in relation to speed, but you can calculate the speed yourself given two sets of gps coords.
Here is a link on how to do this in Java but the idea's will be the same.
http://www.ridgesolutions.ie/index.php/2013/11/14/algorithm-to-calculate-speed-from-two-gps-latitude-and-longitude-points-and-time-difference/
That way you are doing the calculations yourself and not relying on someone else to do it for you.
Related
I was wondering how accurate and reliable is the property speed of a single sample of GeolocationCoordinates API.
I want to take few samples of the current speed of an object (with GPS) and I am not sure if I should calculate the velocity myself (by the distance traveled between two time samples using altitude, longitude and altitude), or just use the property speed of a simple GeolocationCoordinates sample.
How does the speed property is being measured?
Which approach should I take?
The GeolocationCoordinates.speed read-only property is a double
representing the velocity of the device in meters per second.
source, also this might help
So I guess you don't have to calculate it manually.
TIP: For better accuracy, make sure the device is not in battery save mode, as it affects the result a lot.
I'm working on a Google Maps project where we want the customer to type in an Autocomplete address and then be taken to that place on the map.
My manager wants a consistent "viewport" result when compared to the viewport achieved when searching for the same place on maps.google.com.
I found an inconsistent result for a certain location, in particular for the Australian city of Sydney.
The result I get back from Places Autocomplete for Sydney looks quite zoomed in (I used the response's viewport data and call map.fitBounds(...). I'm a first time Stackoverflow user, so I can't post images yet - instead, the effect can be seen by entering 'Sydney, New South Wales, Australia' at the following page: https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete
Alternatively, if I use the Geocoding API instead and take the viewport data response and use that to call map.fitBounds(...), I get a zoomed out view, similar to what I would see when I look for Sydney on maps.googles.com.
I would be very grateful for any suggestions that would provide a solution that gives my customers a viewing result that is 100% consistent with maps.google.com. For example, should I be using a different version of the Autocomplete API, or pass a special parameter? Ideally I would prefer to not be calling the Geocoding to retrieve and override the Autocomplete viewport response, since that would double up my API traffic and double the hit on Google's servers.
I look forward to any advice anybody can offer, thank you!!!
Are you wanting the map zoom level to be consistent after the search ?
I do android with google map. And just by looking at the code from the provided link above.
change that map.setZoom() method to the level you want might help.
I haven't done javascript google map api yet. Just taking a wide guess.
If I am answering the wrong question, please correct me.
I am using JavaScript code to show the multiple pin points on Google Maps using Brownfield. I set the first clicked point as the center point, and when the user clicks on any other point (which is not the center point) I want to display a route mapped from the center point to that clicked point.
I would appreciate help of any sort, including ideas besides using JavaScript.
Google has a number of services available to people who program using their Maps. Go to https://developers.google.com/maps/documentation/javascript/reference and check out the directions services. I'm not very familiar with them, but I'm guessing it's similar to their other services. You make a directions request object supplied with point a and point b, and it will send a message to Google asking for the appropriate directions, which will be returned in some sort of result object that you can use to show the way. Update point b each time the user clicks and resend the google request, and it should update the path. Check out the API and it shouldn't be too hard to get it working. As for alternatives to javascript, Google Maps is written all in javascript, so there really is no other way. But I know from experience, most of their supplied code works really well, so I bet you can get it working!
Following link will show the route between two points:
J2ME/Android/BlackBerry - driving directions, route between two locations
I'm developing a store locator web-application for mobile (iPhone). The idea is standard, the device uses its geolocation feature to determince the location and should then display the 5-10 closest stores on a map. My problem is essentially that I have too many stores (10.000+) and haven't yet been able to create a nice user eperience.
I realize this may be a bit much to ask but I'd love to hear your thoughts on this..
PROBLEM SCOPE:
i) I figure I can only load some of the markers at once rather than all of them which I found that a lot of the <100 stores-finder apps do.
ii) It should be bad connection friendly: i.e. google maps should for example not be made to zoom in and out unecessearily causing new tiles to load (and a empty screen to show if the connection is bad)
iii) it has to somehow cope with the fact that the device gps/tower triangulation can be slow to get an sufficiently accurate fix on your position (often a minute or two if indoors or in an rural area)
SOLUTIONS I've tried:
I) Use getCurrentPositition and from that lat/lng load 5 closest markers. Issue: the snapshot positioning is inaccurate and often the 'wrong' 5 stores are loaded.
II) Use watchPosition until accuracy reaches <100m and then load closest 5 markers. Issue: often takes way to long to get the position (often >1 minute), not a good UX.
III) Same as II only markers are loaded contionously while it finding exact position. Issues: It gets real 'jumpy' using fitbounds() or panTo() every time there is an update. I.e. if the user tries to say click a marker while the map is still in 'find position'-mode they will be intrerupted by the map changing bounds and loading more markers.
IV) Fit bounds to an approximate position using watchPosition and a fixed zoom and use center of the map to get the closest stores. Continously load markers as watchPosition finds a better approximate center or the user himself pans the map. Issues: Again, a bit jumpy since watchPosition updates alot. No 'your position' marker.
BACKGROUND INFO:
I'm using much of the standard google method of creating a store finder, shown here: http://code.google.com/intl/sv-SE/apis/maps/articles/phpsqlsearch.html
Google Maps v3 API, MySQL database, Haversine formula, JSONP asychronous loading of marker-data, no libraries (jQuery or such). Loading 5-10 new markers with this method usually takes less than 1s.
I don't know what watchCurrentPosition is, I'm going to assume you meant to say watchPosition; which is defined in the HTML5 Geolocation spec.
I wouldn't use watchPosition for this. It's technically defined to track changes in position, which don't necessarily translate to increases in accuracy. While I'm not an expert on mobile device power consumption, I'd bet that it uses a lot more power to fire up the GPS and keep it on than to get 1 really good position fix, which is what getCurrentPosition is designed for.
I'd be surprised if this was actually a GPS / sensor fix-time problem. Lots of websites used getCurrentPosition to find the user's current position and most mobile devices can do it within a few seconds, not much different from an AJAX call. I'd play with the PositionOptions settings to set a reasonable timeout, maxAge, and play with the enableHighAccuracy value.
If your 10K stores are within a 2-5 mile radius then you definitely have a hard problem on your hands :-D, but otherwise the data you're getting back from the Geolocation API should be able to narrow it down a handful of stores within a reasonable accuracy. The Geolocation API might not return a lat/lng representing your exact street address, but it should get you a location within the correct city, if not cluster of streets.
I'd decompose this into two problems: 1 - Getting an acceptably accurate position (lat, lng) via the Geolocation API. 2 - Finding stores near position (lat, lng). It'll be much easier to ask focused questions if you're having troubles with part 1 or part 2
I am trying to get some locations in New York using FourSquare API using the following API call:
https://api.foursquare.com/v2/venues/search?ll=40.7,-74&limit=50
What I don't understand is that if the call imposes a limit of 50 search results (which is the maximum), how can I get more locations? When using Facebook API, the results being returned were random so I could issue multiple calls to get more results but FourSquare seems to be returning the same result set. Is there a good way to get more locations?
EDIT:
Ok. So there was a comment saying that I could be breaking a contractual agreement and I am not sure why this would be the case. I would gladly accept a reasoning for this. My doubt is this: Let us say that hypothetically, the location I am searching for is not in the 50 results returned? In that case, shouldn't there be a pagination mechanism somewhere?
The API docs here can help.
Foursquare searching is very closely linked to the location 'point' (the 'll' param on the query) that you provide. The simple answer is that to find more venues within a given area, you need to simply query again with a different location 'point' within that area.
Two queries, both at points close to one another:
https://api.foursquare.com/v2/venues/search?ll=40.700,-74.000&limit=50
https://api.foursquare.com/v2/venues/search?ll=40.705,-74.005&limit=50
will get you two different sets of venues (that may overlap, depending on how close the points are).
The default intent for the search method is 'checkin', which will return the 50 most popular locations closest to that point. If instead you want to look at all the venues within an area, you can use the 'browse' intent. This takes either a 'radius' parameter, in which case it returns venues inside a circle around the given point with the given radius, or it takes two coordinates representing the 'sw' and 'ne' corners of a rectangle. So, you could do:
https://api.foursquare.com/v2/venues/search?ll=40.705,-74.005&limit=50&intent=browse&radius=50
which will give you 50 venues within the 50m circle around that point. A smaller radius will reduce the number of venues returned. So, by varying the radius and the point at which you search (or the size and position of the rectangle described by the 'sw' and 'ne' parameters), you can get more venues returned.
Hope that helps.
The current API limits results to 50. You should try altering your coordinates to be more precise to avoid not finding your venue.
Pagination would be nice but 50 is a lot of venues for a search.