google maps api for webview - javascript

I’m developing an app that integrates Google map with Google places in a webview. I have it all working well using the JavascriptInterface. Actually it’s working really well. However, I just want to know how to set the API key.
At the moment I’m using:
http://maps.googleapis.com/maps/api/js?libraries=places&sensor=true
I want to add the API key. If I add the API key to the above JavaScript I get a message from Google blocking the connection saying that I have to register the URL, which I can’t do as it is integrated in the app.
I have set the SHA key in the Google API Console.
Any Ideas?
Thanks in advance.
.

u should register your website to google map apis key page there is a button rightof key called Edit allowed referers...
and when u are using key
put it to "addyourkeyhere" in link. and set your sensor false or true.
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AddYourKeyhere&sensor=false"/>

Related

GSheet project problems

I'm trying to set a filter to a GSheet with appscript but when I try to run the script appears a popup with:
Google Sheets API has not been used in project blackbox-6831xxxxxxxxx5 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/sheets.googleapis.com/overview?project=blackbox-6834xxxxxxxxxx5 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
When I try to reach that link the console returns me:
The API "sheets.googleapis.com" doesn't exist or you don't have permission to access it
All the other scripts that interact with GSheet API works perfectly.
I have problems only with:
Sheets.Spreadsheets.batchUpdate({'requests': [request]}, ss.getId());
P.S.
I'm the admin
If you don't access directly to the URL, how about going to API console from the script editor and enabling Sheets API? The flow is as follows. Even if you tried this, when the same error occurs, there may be other problem.
Enable Sheets API v4 at API console
On script editor
Resources -> Cloud Platform project
View API console
At Getting started, click Enable APIs and get credentials like keys.
At left side, click Library.
At Search for APIs & services, input "sheets". And click Google Sheets API.
Click Enable button.
If API has already been enabled, please don't turn off.
And then, please confirm whether Sheets API is enabled at Advanced Google Services again.
Enable Sheets API v4 at Advanced Google Services
On script editor
Resources -> Advanced Google Services
Turn on Google Sheets API v4
If this was not useful for you, I'm sorry.

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).

Can I launch an intent using only javascript in an Android browser?

I have a html page that shows the directions from the current location to a certain address.
I would like to do the same but use the map app instead of showing it in a browser.
When I use :
<script>
document.location = "geo:0,0?q=myaddress";
</script>
That works fine but does not show me the route.
What I read from this : Android Google Directions Service usable natively? with wrapper framework? Public transit/biking directions available?
It should be possible using this code :
String url = "http://maps.google.com/maps?saddr=some+address&daddr=another+Address"
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
Can I do the same just using javascript ?
Android is capable of detecting links to Google Maps in the browser and redirect the Intent to the native Google Maps app, if it is set as the default app. There is, however, no way to force the user to use the Google Maps app. Clicking the link can also show him the activity chooser or open Google Maps in the browser. It might also open a third-party app that is registered to handle the same Intent. The code snippet you posted will behave exactly like that, too.
This not only works from the browser, but with all links in the system. For example, I sent the link you posted via e-mail to myself and clicked it on my phone. I could open it with my Goolge Maps app. So there is really no need for JavaScript, you can just use a simple HTML link to send the Intent.
Just simply call the function from JavaScript to Android , and inside the function you can call the android intent.
you can find out the tutorial how to call android function from JavaScript:
http://android-er.blogspot.in/2011/10/call-javascript-inside-webview-from.html
and call the map using Google V3 library .
https://developers.google.com/maps/articles/android_v3

How can I detect internet connection in Asp.Net MVC to use Google Maps?

I am developing an Asp.Net MVC application that uses Google maps to show Addresses in a map. The problem is that I need to demo the app in an environment not connected to internet. How can I detect with an script that the app is disconnected not to call the Google maps api functions?
Very similar question to this one. Allen Bargi's answer pointing to the jQuery plugin I think would be the easiest way to detect offline and online, firing an AJAX call to determine whether your MVC application has access to the web.
Another thing you could think about is looking into the Google Gears API which would allow you to work with Google Maps offline. Or so my understanding goes, haven't personally tried it though ... yet :).
This should get you there
using System.Net.Sockets;
private void example{
Boolean isConnected;
TcpClient tcpClient = new TcpClient();
tcpClient.Connect("maps.google.com", 80);
isConnected = tcpClient.Connected;
}
Do you need to do anything this fancy? could you not put a key in the web.config to change when you are in demo mode?

How to make a Google Maps API (.js) file a part of a widget for Mobiles

I would like to create a Web App for device. For that I would have some script being stored on device, instead of downloading them all time when I start application. As far as I saw including a GoogleMaps API makes some additional request for javascript files. Is there any way of having all of them taken directly from local store? Or is this always have to refeer to google web address? Thanks for any answers here!
No, you always must load them from the Google site. They offer no way to run Google Maps locally. The GMaps scripts are generated on the fly, based upon (among others, I'm sure) the HTTP_REFERER header of the request. That's how they can bind an API key to a specific website.

Categories