What constitutes a call to the basic Google Maps JS api? - javascript

Just for background, I have an app which runs in both the browser and as a hybrid PhoneGap app, and which uses the Google Maps JS api.
Essentially, users pan and zoom the map and when a 'map idle' event is triggered, the app queries my API based on the current bounds of the idle map.
I'm just trying to find out what constitutes a call to the JS api?
Does one map load/init equal one api call, regardless of how many times a user pans, scrolls and zooms the map?
Or is each pan, scroll and zoom an api call (in other words, every time the map bounds are changed so new tiles need to be loaded?
Or (worst case) is every new tile that needs to be loaded a separate call to the api?
Or something else?
Anyone shed any light on this?
Thx.

As stated in the Google Maps API:
A single map load occurs when:
a map is displayed using the Maps JavaScript API v3 when loaded by a web page or application;
a Street View panorama is displayed using the Maps JavaScript API v3 by a web page or application that has not also displayed a map;
a SWF that loads the Maps API for Flash is loaded by a web page or application; or
a single request is made for a map image from the Static Maps API.
a single request is made for a panorama image from the Street View Image API.
The degree to which a user interacts with a map once it has been loaded has no impact on the usage limits.

Related

Passing KML files to Google Maps

I just became aware of KML files, did some reading and generated my first KML files off of google maps. In my app I am linking to google maps, passing a publicly available file with the intent of opening the KML file on the users Google Maps or Chrome browser (not within my app). Maps, or Google opens, but the kml file data/map isn't loading. To confirm its public, the URL attempts to download the file from my website.
Doing a simple call like:
window.open("https://maps.google.com/maps?q=https://myserver.com/files/maps/testMap.kml")
Maps successfully opens, but I get a "No Results Found" pop up. I do see my URL passed into the query section of the map - and the zoom is in the middle of the ocean off of Africa...and when I zoom to the map location (Tampa FL) nothing is there.
What am I missing here?
Google Maps no longer supports opening a KML file directly on the main page at maps.google.com. You used to be able to enter the URL for a public KML file right in the Google Maps search bar and have it load directly, or load the KML via a URL parameter like you have in your question (?q=http...), but that functionality was turned off some time ago.
Now, to load a KML file on a Google Map, you'll probably need to set up a web page with a Google Maps API instance on it, where you can use the API to load a KML file. If it's a relatively simple KML, you could also try uploading it to a Google My Map, and using the share functionality in there to share a link or get an embed code.

Is it possible to control which Google Maps scripts get fetched (JavaScript API)?

So I am using Google Maps for an autocomplete text input for cities. The script I'm calling has an src like this:
https://maps.googleapis.com/maps/api/js?libraries=places&callback=initAutocomplete&types=(cities)
I see in the network tab that this actually downloads quite a few external google scripts:
common.js
util.js
controls.js
places_impl.js
stats.js
Collectively, these scripts are over 100kb... That's equal to the size of my entire application (gzipped). Is this really necessary just for a places autocomplete? Is there any way to pass params into the request url that control what is downloaded?
Those are all scripts which Google Maps JS API need to function properly, to display Map, etc. But if you want ONLY Places Autocomplete, and you don't even want to display the map, then there is a way for you to not download ANY libraries.
Just make a request to Google Places API, something like:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=TEXT&types=(cities)&language=en&key=YOUR_API_KEY
for autocomplete results every time user inputs something into you search input box (or preferably with some throttling). Google Places API is not part of Google Maps JS API you are using in your project, it's a separate API only for Places.

Google maps API v3 - How are client loads detected?

I have a small and low key website what features Google Maps using the v3 Javascript API.
Not that I am expecting to get over 25,000 loads per day, but how does Google detect people loading the map on my site? My site uses the the following code http://maps.google.com/maps/api/js?sensor=false without any API key, and as it is rendered in the clients browser, how does Google relate it to my site?
Is the loads worked out through the http headers/referrers or are the loads based on how many times each client/IP loads the map?
In essence, the code for the map is rendered on my clients/users browsers and thus how do Google know how many people are using the map on my site?
Finally; although I have Google web master tools; is it worth creating & using a API key, or will it just make it possible for Google to track how many people are using the map on my site and thus apply the limit of 25,000?
The API sends a request to google which contains the URI of the page that contains the map(when you inspect the network-traffic inside the dev-tools you'll see a request to https://maps.googleapis.com/maps/api/js/QuotaService.RecordEvent ) . This request will be sended when a Maps-instance has been created successfully.
The benefit of using a key: google is able to contact you when there are issues(e.g. may send a notice when you have reached any limits and give you a chance to react/solve the issue before they restrict the API-access for your domain/account).

Android Google maps app vs using Android WebView to view Google maps embedded in webpage

I'm working on an Android app that needs to be able to display information on Google maps.
I'm considering two ways of implementing this:
Use the Google maps api provided for android with the MapActivity class
Or I could use the javascript google maps api and view the map data on my phone through a WebView rather than using a MapView.
Would anyone be able to list any advantages/disadvantages of these methods?
Would the WebView be as responsive as the Android Google Maps app?
Thanks heaps
I won't go far to conclude which is the best, but still these are things that I encountered upon trying for both approach.
Customizable:
Web View: requires you to have a web server (or at least one html page) as basis for your custom overlay via js (or perhaps you can directly draw the overlay over the WebView but having consequences to face nightmare of projecting the geoposition with the screen position)
GMap API: overlay is drawn directly over the MapView.
Download time:
Web View: when one write an html page for mobile view, s/he should consider the varying capability of downloading speed. If you carefully write the html page to fit for mobile download then it should be fine.
GMap API: the data transferred is already managed by the API and should be already in effective and minimum way.
Current Issues:
Web View: can fit to fragment mindset of Android programming
GMap API: no news so far I heard of, hopefully they're working on it. Since fragment is the new standard.
Cheers.

google maps and scopes within greasemonkey

I am writing a greasemonkey script that will allow its users to click a button and view a popup map. I am going to try and use google maps for actually creating the map and plotting a few points. I have a couple of questions about this however.
First, would using script to create an iframe within my popup div that calls a script from my server have to use an api key for my server, or would it have to be a key for the site the greasemonkey script will run on?
Secondly, if this fails is there a way to use JS to plot points on an image like image magick does for PHP?
If you use Google Maps Javascript API V3 you don't need API keys anymore.
To generate images with javascript, you could use the new <canvas> element: https://developer.mozilla.org/en/canvas_tutorial

Categories