External Lib google maps geometry - AngularJS - Bootstrap

This forum contains topics that were moved from Get Satisfaction
Ravenight
Posts: 0
Joined: Sun Jan 11, 2015 3:43 pm

External Lib google maps geometry - AngularJS - Bootstrap

Post by Ravenight »

I am very happy to see the ability to edit external libraries and dependencies after the latest update.

I am having an issue getting the following to load:
https://maps.googleapis.com/maps/api/...

I have gone into App settings and added it as an external lib that is not global with a shim enabled and a dependency on gmaps.
name: google_maps_geometry
url: https://maps.googleapis.com/maps/api/...
type: External lib
Enabled: Yes
global: no
shim: yes
shim export: [BLANK]
shim init code: [BLANK]
deps: gmaps

When I then try to call a function in this library:
codevar distance = google.maps.geometry.spherical.computeDistanceBetween(map.center,$scope.map.lastCenter );/code

I am getting this error:
codeCannot read property 'spherical' of undefined/code

I can console.log(google.maps) and everything is there but the geometry library.
Any idea why it is not loading the "geometry" functions? I assume it is something with my external lib setup.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

External Lib google maps geometry - AngularJS - Bootstrap

Post by Yurii Orishchuk »

Hello,

Please follow these steps:

1 Open your app settings on "External resources" tab.

2 Take a look on "User-defined resources" part. There should be.

pre

http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places

/pre

3 If you can not find it - add it there. Details: http://prntscr.com/536jl3/direct

Regards.

Ravenight
Posts: 0
Joined: Sun Jan 11, 2015 3:43 pm

External Lib google maps geometry - AngularJS - Bootstrap

Post by Ravenight »

That is where I was adding the data, but I tried it again with the following:

name: gmaps_geometry
url: http://maps.googleapis.com/maps/api/j...
type: External lib
Enabled: Yes
global: No
shim: No

and this worked, sorta.
The geometry is not loaded when the map tiles are first available. I put in a check to make sure the google.maps.geometry is there and on subsequent map tile loads it works fine.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

External Lib google maps geometry - AngularJS - Bootstrap

Post by Yurii Orishchuk »

Hi Ravenight,

It seems to be a bug for angular project.

We are working on it. And will response you here as soon as we will have any update on it.

Thanks.

Ravenight
Posts: 0
Joined: Sun Jan 11, 2015 3:43 pm

External Lib google maps geometry - AngularJS - Bootstrap

Post by Ravenight »

As I was trying to add the places library I believe I discovered a related item. The angular-google-maps has added the "geometry" library and regardless of my external attempt to load this is irrelevant.

I disabled the call to this external library and my geometry continued to work. I noticed uiGmapGoogleMapApiProvider was loading the library.

How do I edit this in the framework:
code
.config(function(uiGmapGoogleMapApiProvider) {
uiGmapGoogleMapApiProvider.configure({
// key: 'your api key',
v: '3.17',
libraries: 'weather,geometry,visualization'
});
})/code
I can hack it by editing the source file for the angular-google-maps.min.js file and enter the library name in the libraries area.

I don't like hacking the framework.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

External Lib google maps geometry - AngularJS - Bootstrap

Post by Illya Stepanov »

We have reported this bug and we are working on fixing it, at this point we can't suggest any solution, unfortunately. Hopefully we will fix it and everything will work correctly.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

External Lib google maps geometry - AngularJS - Bootstrap

Post by Alena Prykhodko »

Hello,

App uses require.js for resources loading.

You can find your library in bootstrap.js - as alias in require config and in app.js as last dependence module.
Library is written in global area scope.

Bruce Buttles
Posts: 0
Joined: Tue Oct 20, 2015 7:44 pm

External Lib google maps geometry - AngularJS - Bootstrap

Post by Bruce Buttles »

Hmmm, I am having the same error:

"User transformation function exception. Reason: Cannot read property 'spherical' of undefined"

Here is my code where p1 and p2 are LatLng objects and have valid values:
code
var distInMeters =google.maps.geometry.spherical.computeDistanceBetween(p1, p2);
/code

FIRST, I tried to add the library as a user-defined library as Yurii recommended - BUT - I then get this error:

"You have included the Google Maps API multiple times on this page. This may cause unexpected errors."

I desperately need a way to calculate the distance between two point on a map... can you help please?

Serhii Kulibaba
Posts: 147
Joined: Tue Aug 27, 2013 1:47 pm

External Lib google maps geometry - AngularJS - Bootstrap

Post by Serhii Kulibaba »

Hello Bruce,

Have you added google's geometry library into the app? https://maps.googleapis.com/maps/api/...

Post Reply