Google maps - current location - no HTML5 - html

I am using google maps on a simple HTML website. I can center the map on user's current location using HTML5, but that requires getting permission from the user.
Now, when I go to maps.google.com, the map is centered around my location pretty accurately, without asking my permission.
How can I do that? When I define the map in my HTML webpage, I need to identify the center. How can I set the center to the center that google maps automatically finds?
Thanks.

assuming your in chrome go to the google maps page, then press f12 goto the resources tab, expand local storage, session storage and cookies, delete all entries from there, close the tab, go back to maps, notice it will no longer have your location, you'll need to click on the sniper type gps icon and it will ask you in you browser if you want to allow location.
answer being it has to ask you for permission, there is no compromise whether it's google or anyone else.

Your only other option, if you are serving any content server-side, would be to attempt to get the user's location from his or her IP address. There are a handful of APIs and services out there that will give you approximate locations, but your mileage may vary greatly. And, as I mentioned, you would have to execute that code server-side and then return some lat-long back to the client side to initialize/update your map.

Related

Download programmatically on Google Maps an offline area

I would like to know if there is a way to make my Android app trigger the download of an offline area in Google Maps app.
Yes, there is.
click the menu at the left side of the blank, choose 'offline map', you can choose the scope/granularity of the map.
If you are open to use other map services, I recommend to use HERE map, it can even calculate path without internet connection.

Google Chrome Extension Top Sites Images

So using the Google Chrome Top Sites api has values for the url and the title, but when you load the default google chrome page it also has an image of those sites, is there any way to get that sort of image for an extension? If not how does google get that image and how can you get an image of the the user's top viewed website?
Since that it isn't possible to get a screenshot of a page without loading it inside a tab, Chrome is simply getting those screenshots while you're browsing your favourite sites. You can tell this easily because sometimes sites and images do not coincide (e.g. sometimes my facebook.com top site has the image of my profile page, but links to the home).
Then, if you want your screenshots of the Top Sites, you'll have to start without screenshots, and create them while the user browses the web by using the chrome.tabs API to check when a tab loads one of the Top Sites (listening to the event onUpdated), and get a screenshot of that tab using captureVisibleTab.
NOTES: make sure that you've requested the permission for "<all_urls>" in your manifest, which is required for captureVisibleTab to work. Additionally, you may find this question and its answer helpful.
It's unfortunately not possible*. Chrome stores those thumbnails internally in URIs not accessible from an extension.
There is an existing feature request: https://code.google.com/p/chromium/issues/detail?id=11854
If you look at the comments, one of the main use cases is to access site thumbnails to replicate the New Tab page.
Do star the feature request above to raise its priority if you want this functionality implemented.
* By that I mean that it's not possilbe to access Chrome's own internal store of thumbnails.
Furthermore, as Marco suggested the way to replicate that would be tab capture, but you can't do it "in the background" for privacy reasons - a user must make an explicit gesture (e.g. click the extension's button, press a shortcut, etc.) to perform capture.
Marco's answer is valid now, captureVisibleTab should be accessible upon events. But yes, as of now Chrome forces you to have very broad permissions and maintaining your own thumbnail store.

How to Show Driving Directions on New Google Maps via URL Link

I have a simple Google Maps link on my site that opens a new page and loads the driving directions from our location to customer's address.
The link is something like
https://maps.google.ca/maps?saddr=[our address]&daddr=[customer address]&dirflg=d
Where [our address] is replaced with our address and [customer address] is replaced by the customer address. The Google Maps is loaded properly with the directions drawn out on the map but is there a way to expand the "List all steps" for the default selected direction on page load?
I'm guessing Google Maps will automatically load the "best" route when the page is loaded but currently the user has to manually click on the "List all steps" to view the step by step directions. I want it so that when the user clicks the link on my site then it'll automatically load the map directions along with the step by step directions already opened. Is there some kind of special URL parameter that I can pass to do this?
I've been looking for the same solution - If you are able to format the link in the following way this works:
https://www.google.com/maps/dir/[customer address]/[our address]/am=t/
It would be good to figure out how to submit it from a standard HTML form though.

Current Location asked though not needed

In an iPhone app I am opening a UIWebView object that I load with a URL like the following:
https://maps.google.com/maps?q=36.294384,-85.749443&iwloc=A&hl=en
(an arbitrary location, somewhere on the planet)
The strange thing is that I get asked the permission to use the current location, when clearly I have no use for it. Why is that?
The fact is, the app works in any case, regardless of my answer to the question above.
But why the question in the first place?
It's because the Google Maps website is using Safaris web API to ask for location. One can get a persons location using Safari and Google uses this functionality in their web version of maps.
edit: It's not currently possible to disable this prompt in the UIWebView (or any browser for that matter)

Google Maps API v3 - how to save map into cookie/localstorage

I'm building a page which loads a google map, with street view on another div on the side and I would like to save that data so if the user closes his browser window and then comes back that it will bring it up again without the need to call the Google Map API again.
I've tried saving the div contents and replace it with the current one incase the user visited already.
I tried with cookies but couldn't save much information due for size limit of 4kb and I've tried localStorage (HTML5) but it didn't work as expected.
Any ideas?
Thanks