How can i add API key in this Google maps code - javascript

I have played enough with this code.
Mostly from line 1558-1680 but didn't find any solution.
It would be a great help if anyone could help me to add my API key to the link.
I am getting error "no API key" in console and the code works locally but doesn't work online
https://gist.github.com/anonymous/8dd127ffb42709348613d3cfcf056c63
credits to CodeXTree this code belongs to them.
PS: sorry for such a huge code

The API key belongs at the end of the script tag where you include the Google Maps js in your header or footer.
<script type="text/javascript" src="//maps.google.com/maps/api/js?key=YOUR_KEY_HERE"></script>
The gmaps.js code you linked to gets included below google maps:
<script type="text/javascript" src="path/to/gmaps.js"></script>

Related

Google Maps API error: MissingKeyMapError on another domain

The number of the problem related questions is huge. I spent a lot of time and probably took a look on each of them, however I haven’t found a solution for my case.
There is a domain (let's call it domain.com). Google maps is connected to it with the key for years: <script src="//google.com/jsapi?key=the_key_is_here"></script>
There is a new domain (let's call it domain-new.com) - the full clone of the first domain. But the Google Map doesn't work on it and there is an error in the console: Google Maps API error: MissingKeyMapError.
What methods of solution have I tried:
Creating a new key
Include all Google Maps APIs in console.cloud.google.com
Specify all possible referrers in console.cloud.google.com:
domain.com
*.domain.com/*
domain.com/contact
domain-new.com
*.domain-new.com/*
domain-new.com/contact
Specifying the versions of the included script (?v=3/?v=3.exp/?v=3.26)
Replace the included script with: <script async defer src="//maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&key=the_key_is_here"></script>
All the changes were made simultaneously for domain.com and domain-new.com. The map worked successfully on domain.com, but there still was an error on domain-new.com.
Therefore, the exactly same map with the same key works on domain.com at the moment, but nevertheless it doesn't work on domain-new.com. All relevant documentation for the Google Maps API was read and no suitable solutions have been found. In conclusion, I hope your will help me.

External Javascript file returning 404 error in django

<head>
<!-- Include Google Maps JS API -->
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/?key=my-KEY&sensor=true">
Each time I call the view up the other html element show but the google map is not displayed. the console reveals a GET https://maps.googleapis.com/maps/api/?key=KEY&sensor=true 404 ()
PLS how will I load an external js in django?
This is not a Django error in fact.
However, the solution is to switch to googleapis.com. Maps APIs should now be loaded from maps.googleapis.com rather than maps.google.com or maps-api-ssl.google.com.
Edit
In fact, you are using maps.googleapis.com. This means that the error is caused by something else. I think that the problem is that your link is missing js after ?. See here.
Google Maps Static API is free and you can authenticate by API_KEY.
Google Maps Javascript (JS) API is not free any more and API_KEY authentication was disabled. For that reason you get 404 and 400 web response status.
https://developers.google.com/maps/documentation/maps-static/start
Reminder: To use the Maps JavaScript API:
All Maps JavaScript API requests must include an API key; we no longer support keyless access.
You must enable billing on each of your projects.

Add JavaScript to Google Sites

My goal is to create a nice radar chart, which I'd like to display on my Google site. I found the rcharts website quite helpful. My question is now, how do I implement the simple java script code on my Google Site? An example of what I'm after is a demo in the RGrqaph download:
https://www.rgraph.net/download.html#stable
And it's called: demos/radar-basic.html
Thank you very much!
I tried the link proposed below as well, however, I get the following error when I post everything into the HTML box: 2+13 - 30: failed to load external url RGraph.radar.js
Sceenshot
Any suggestions?

Google Maps Places API: TypeError: autocomplete is undefined

Whenever I am trying to use the Google Maps API places library it gives me this error in the console of my browser:
TypeError: autocomplete is undefined
If I'm not mistaken, that means the places library couldn't load. As for the code, I had my own code but I also copypasted the code from the Places API tutorial(https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform).
In my header I have these two lines included:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=MY_KEY_HERE"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
I also made sure Placis API, Google Maps JavaScript API v3 and Google Maps Geolocation API are all switched on in my Google APIs console.
I am not really sure what the problem is, besides the places library not loading. I should note I am working on a hidden subdomain, could that be the problem?
Thanks in Advance.
Please make sure you only load the maps file once (and you should always load the api via https, or with the active protocl):
<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?key=MY_KEY_HERE&libraries=places&sensor=false"></script>
The subdomain should not be a problem, so you can work with it.

Live widget generation for users

I have created a widget for users which they can embed to their site using the following code
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="http://www.socialfeastalpha.com/widget/xss_magic.js"></script>
<div id="socialfeast-widget"></div>
I want users to be able to customized the widget according to their needs.
any help is highly appreciated.
Thanks..
Simple solution: Make the URL to the JS script actually generate a unique script for each user.
Better solution: Make your users call a callback from your script with some identification information, ala Google Analytics.

Categories