Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading Google Maps javascript v2 to v3 using Business Client IDs

I am using this link for Upgrading Google Maps JavaScript Application v2 To v3. Basically my approach is to get the output from api, parse it and load it using MapKit framework, which i am succeeded in doing it using this code.

My problem : As per the documentation,if we are using google maps for Business customer, we will need to use a Client ID in place of a Key.

so if I use this code:

<script src="https://maps.googleapis.com/maps/api/js?v=3&client=gme-myclientId&sensor=false" type="text/javascript"></script>

i am getting following output, where all the locations are plotted at single point (probably centre) :

map current output

if i use this code:

 <script src="https://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script>

i will get the expected (correct) output as follows:

map expected output without using clientId

I also ran through this documentation for correct use of client id, but dint help. I am using the same client id that was used for v2, hope that should not create any problem.

like image 293
Krishna Shanbhag Avatar asked Nov 02 '22 23:11

Krishna Shanbhag


1 Answers

Thanks for all the comments to my question, which made me to solve the problem. So, i thought of sharing the solution.

when i am not using the client id,

<script src="https://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script>

the response structure is

"overview_path": [{
                    "jb": 37.785610000000005,
                    "kb": -122.41127000000002
                }, … ];

But, on using the client id, say gme-myClientId

<script src="https://maps.googleapis.com/maps/api/js?v=3&client=gme-myClientId&sensor=false" type="text/javascript"></script>

the response structure is

"overview_path": [{
                    "hb": 37.785610000000005,
                    "ib": -122.41127000000002
                }, …];

So, variation in jb,kb to hb,ib was causing the problem, since i was using the variables as key to get the values.

I was using a third party Code which internally follows this procedure.

I mailed Google enterprise support and they replied me back saying i might be using some of the undocumented variables in my Javascript library. The variable names are automatically generated when the library is minified and can (and often do) change on every release they push. The correct way is to use the documented API methods only.

link for using documented API methods can be found Here

i modified my code to use like the below

var latT = someLocationObject.lat();
var longT = someLocationObject.lng();

and it worked for me.

like image 55
Krishna Shanbhag Avatar answered Nov 11 '22 06:11

Krishna Shanbhag