What I really want to do is to allow a user to create a map with google maps and save the image. I have attempted a work around that does this by using the google maps api V3 and also the static maps api.
The user can use the dynamic google map to scroll, zoom, etc and find a map they like. The user should then press a button which extracts the data from the google map (center, zoom level, etc) which sends the query to the static google map api. The static google map api will then return the image which can be saved.
I have this all working* except it doesn't always work. Sometimes the images returned by static google maps will be exactly what the user sees in the dynamic map. Other times the image may be off by a few meters (I believe this is because the dynamic google map api uses greater precision for longitude and latitude than the static api), or even thousands of kilometers (I have no idea why this happens). The images are usually off the greater the zoom level is (because of the precision differences).
I want to know if anyone has tried converting a dynamic map to a static map and came up with a non-buggy solution, or if there is a better solution that works.
Go to the Google Maps Platform > Credentials page. On the Credentials page, click Create credentials > API key. The API key created dialog displays your newly created API key. Click Close.
Note that the Maps Embed API, Maps SDK for Android, and Maps SDK for iOS currently have no usage limits and are at no charge (usage of the API or SDKs is not applied against your $200 monthly credit).
Go to APIs & Services → Dashboard → Enable APIs & Services at the top and Choose Maps Javascript API from the API Library. This will open up the Map JavaScript API page, and Enable it.
The Google Maps Platform static web APIs let you embed a Google Maps image on your web page without requiring JavaScript or any dynamic page loading. The APIs create an image based on URL parameters sent through a standard HTTP request and allow you to display the result on your web page.
"...I believe this is because the dynamic google map api uses greater precision for longitude and latitude than the static api..."
AFAIK In the both the Google Maps V3 and the Static Maps api Latitudes and longitudes have a precision to 6 decimal places. Precision beyond the 6 decimal places is ignored. This seems to be the point made in both these docs, athough the one pertaining to the Maps api does state (my emphasis).
"With the current zoom capabilities of Google Maps, you should only need 6 digits of precision after the decimal"
Static http://code.google.com/apis/maps/documentation/staticmaps/#Usage
Regular http://code.google.com/apis/maps/articles/phpsqlajax_v3.html
Without seeing the code you are using it is hard to say what the root issue of your problem is though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With