Loading multiple maps libraries with javascript - google-maps

I am trying to load both the maps library and the places library with javascript so I can embed a map into my page, use google.maps.geometry.spherical functions and make places search requests but I'm having trouble loading all 3 libraries.
At the moment I am importing:
<script type="text/javascript"src="http://maps.google.com/maps?key=mykey"></script>
<script type="text/javascript"src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
But I get the errors:
syntax error
[Break On This Error]
...gs4d .gbmac,.gbes#gbg4 #gbgs4d .gbmac{margin:34px 0 0}.gbemi#gb #gbgs4d .gbmac,....
maps?k...hrkDAmw (line 1)
GClientGeocoder is not defined
[Break On This Error]
var geocoder = new GClientGeocoder();
Where am I going wrong?
Thanks a lot.

The first script doesn't point to a javascript, this will try to load the maps-homepage as a script(of course this will fail).
There is no need to include multiple scripts, simply use:
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?libraries=geometry,places&sensor=false">
This will load the maps-API(V3) and includes the places+geometry-libraries
https://developers.google.com/maps/documentation/javascript/libraries?hl=en
However, as Colin said, this looks like V2-code.

You can use it in this way
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY&libraries=places"></script>

Related

google.visualization.arrayToDataTable is not a function

Hi it's first time writing a post.
I am trying import google chart in javascipt. Some reason I keep on getting error of "google.visualization.arrayToDataTable is not a function".
I have imported google api in my jsp.
Check the source code and make sure the API is included:
<script src="//www.google.com/jsapi"></script>
Then the type of visualization you want to use must be loaded. For example:
<script>
google.load('visualization', '1', {packages: ['imagechart']});
</script>
Please provide some source next time you post a question :)

google map api v3 in app

I am creating an app that uses google map. i inserted the map api key inside the html page.
<script type="text/javascript" src="https://maps.googleapis.com/maps/api /js?key=AIzaSyDcvUkjiKRkJ2zV8cYElZy55JLZDjiL9g8&sensor=false"></script>
i keep getting error saying " Google has disabled use of the Maps API for this application. The provided key is not valid Google API key, or it is not authorized for google Maps Javascript API v3 on this site ". i just followed whatever they had mentioned in here
https://developers.google.com/maps/documentation/javascript/tutorial#api_key
i don't have any problem when run this code in my html. Only problem is that some of the map page don't render out properly. Which version is better to use V2 or V3 ?
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
i am kinda confused. Can someone help me out what i doing wrong or what do i need to do. Since my app is totally based google map. Thanks
I see two possibilities for you:
Either you use this line in your code <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=CHANGE_YOUR_KEY_HERE&sensor=false"></script> and you generate a new key for you application: https://developers.google.com/maps/documentation/javascript/tutorial#api_key
(on the screenshot you can see the link "Generate new key...")
Or you use this line without bothering with having a key. (for example: http://jsfiddle.net/LZmQ2/)

Google Maps loading files twice

I have really strange problem with Google Maps. Before closing body tag i'm putting this line:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=API_KEY_IS_HERE&sensor=false"></script>
And when I'm trying to load the page I get such error:
Uncaught TypeError: Object #<Object> has no method 'Load'
I investigated a little bit, and I know that the problem is connected with loading google maps files twice. I previewed the file and google maps appends two libraries:
<script src="https://maps.gstatic.com/intl/pl_pl/mapfiles/api-3/15/11/main.js" type="text/javascript"></script>
and
<script src="https://maps.gstatic.com/intl/en_us/mapfiles/api-3/15/11/main.js" type="text/javascript"></script>
It's loaded dynamicaly. I think that the problem is with two languages: pl_pl and en_us. But why is it happening? Do You have any ideas how to solve this weird issue ? :D
Remove this script from the source:
<script src="https://maps.gstatic.com/intl/en_us/mapfiles/api-3/15/11/main.js" type="text/javascript"></script>
It will be loaded automatically by https://maps.googleapis.com/maps/api/js?key=API_KEY_IS_HERE&sensor=false

The provided key is not a valid Google API key Ext JS issue

I got some issue in Google Map api in my project. I didn't handled anything related to this part and it was working fine before today.
But now, If i run the application, i got this popup msg and after that, the pages that are using google map api aren't working with this error.
I googled and followed this step.
1) https://code.google.com/apis/console/b/0/#project:40595208241:access
2) generate a new key
3) copy the new key to the index.htm inside key value
<script src="http://maps.google.com/maps?file=api&v=2.x&key=AIzaSyAJz86xjTce_oqnSTw8MoNaY-13tIx03XU" type="text/javascript"> </script>
<script type="text/javascript" src="extJS-ux/GMapPanel.js"></script>
<link href="extJS-ux/Ext.ux.grid.RowActions.css" rel="stylesheet" type="text/css" />
<script src="http://www.google.com/jsapi?key=AIzaSyAJz86xjTce_oqnSTw8MoNaY-13tIx03XU" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1');
</script>
So i've followed this same step, but now it doesn't work anymore. It doesn't show the error msg anymore, but it doesn't also show up the result. It says no result and do nothing. It worked right yesterday!!
I tried to do some other ways, but there wasn't a good solution for this.
Can you help me with this?
You are using v=2.x (the "experimental version). That is not recommended for production sites. It might start working if you call for v=2 or v=2.s (the "stable" version), if this was a change in the API.
Note that you are using v2 of the Google Maps API which is deprecated and may stop working May 19, 2013; definitely not recommended for production sites.

Unable to display google maps in a dojo layout

I am a real newbie in programming and now I have to combine Google Maps and Dojo. Both alone are fine but when I try to implement a Google Map into a Dojo content pane which is embedded in a border-container it simply does not work. I think there is a problem with the naming of the divs but perhaps there is something else to take care of?
Could someone post the simplest possible solution?
many thanks
I was able to figure it out myself.
Here is the answer:
Actually I was going to use ArcGIS Server Javascript extension for GoogleMaps and Dojo together. Thus we have to sure that all references to APIs are made correctly.
I think it is wise to use the Dojo components directly from the ArcGIS Server-API pages instead of loading from the DOJO network. This should guarantee the compatability between all components.
<!--Load Google Maps API -->
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA22G6YWIfghc6CfXo3jGlQBQIhNZriPAS64ZF0ztgQFnJUtUvlhSuBly8ueb8pLmxY8qzKANsSXJhUA" type="text/javascript"></script>
<!--load arcgis-javascript for googlemaps api -->
<script src="http://serverapi.arcgisonline.com/jsapi/gmaps/?v=1.4" type="text/javascript" ></script>
<!--load arcgis js api -->
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.4"></script>
<!--load the required Dojo components -->
<script type="text/javascript">
dojo.require("dojox.data.XmlStore");
dojo.require("dojox.grid.DataGrid");
<!--This loads the esri specific geoprocessing tool -->
dojo.require("esri.tasks.gp");
<!-- defining variables -->
var gmap = null;
var dynMapOv = null;
</script>
Then, after the initializing function is set up...
function initialize() {
//Load Google Maps
gmap = new GMap2(document.getElementById("gmap"));
var centerat = new GLatLng(-1, 23.7);
gmap.setCenter(centerat, 3); ...
... one has to ensure load the function with
dojo.addOnLoad(initialize);
Furthermore, it is important to put a reference to the the dojo-theme in the body tag of the HTML code.
<body class="soria" onunload="GUnload();">
I hope this very basic stuff helps someone who is not sure about how to combine AGS+GoogleMaps+Dojo.