Comments (6)
Hmm. Not sure. GoogleMaps.load()
is in an onBeforeAction
(which does often run multiple times), but that load method can only run once thanks to underscore's _.once()
. See source here.
I also load the library the same way in multiple apps and don't have the issue, so are you sure there's not another spot that you used the GoogleMaps.load()
and forgot to remove it?
from meteor-geocomplete.
Yeah, routes.js is the only place
grep 'GoogleMaps.load' * -aR
app/.meteor/local/build/programs/server/app/lib/routes.js: GoogleMaps.load({
app/.meteor/local/build/programs/web.browser/app/lib/routes.js: GoogleMaps.load({
app/.meteor/local/build/programs/web.browser/app/client/templates/rides/create_ride/create_ride.js: if (GoogleMaps.loaded()) {
app/.meteor/local/build/programs/web.browser/packages/dburles_google-maps.js: if (GoogleMaps.loaded()) { // 79
app/.meteor/local/build/programs/web.browser/packages/dburles_google-maps.js.map:{"version":3,"sources":["dburles:google-maps/google-maps.html","dburles:google-maps/google-maps.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kC;AACA,wE;AACA,kB;AACA,sF;AACA,I;;;;;;;;;;;;;;;;;;;ACLA,mD;;AAEA,c;AACA,kC;AACA,gD;AACA,8F;AACA,kD;AACA,oC;AACA,sE;AACA,wC;;AAEA,sC;AACA,K;AACA,uB;AACA,sC;AACA,qC;AACA,I;AACA,kC;AACA,sB;AACA,8B;AACA,I;AACA,W;AACA,iB;AACA,0B;AACA,2B;AACA,kD;AACA,oD;AACA,sC;AACA,wB;;AAEA,wC;AACA,O;AACA,I;AACA,+B;AACA,gD;AACA,2B;AACA,gB;AACA,O;AACA,I;AACA,6B;AACA,gC;AACA,iC;AACA,8C;AACA,gE;AACA,2C;AACA,I;AACA,iC;AACA,uB;AACA,0B;AACA,2B;AACA,4B;AACA,S;AACA,O;AACA,uB;AACA,2B;AACA,I;AACA,oC;AACA,oB;AACA,uB;AACA,iC;AACA,8B;AACA,M;;AAEA,gD;AACA,wC;AACA,yC;AACA,Y;AACA,iF;AACA,2C;AACA,S;AACA,K;AACA,G;AACA,E;;AAEA,0C;AACA,kB;AACA,4B;AACA,4B;AACA,8B;AACA,wC;;AAEA,yB;AACA,e;AACA,sB;AACA,sE;AACA,M;AACA,gD;;AAEA,uB;AACA,+C;AACA,4C;AACA,8E;;AAEA,qC;AACA,mB;AACA,8D;AACA,6B;AACA,S;;AAEA,e;AACA,K;AACA,K;AACA,G","file":"/packages/dburles_google-maps.js","sourcesContent":["\nTemplate.__checkName(\"googleMap\");\nTemplate[\"googleMap\"] = new Template(\"Template.googleMap\", (function() {\n var view = this;\n return HTML.Raw('<div class=\"map-canvas\" style=\"width: 100%; height: 100%\"></div>');\n}));\n","var supportedTypes = ['Map', 'StreetViewPanorama'];\n\nGoogleMaps = {\n load: _.once(function(options) {\n options = _.extend({ v: '3.exp' }, options);\n var params = _.map(options, function(value, key) { return key + '=' + value; }).join('&');\n var script = document.createElement('script');\n script.type = 'text/javascript';\n script.src = 'https://maps.googleapis.com/maps/api/js?' + params +\n '&callback=GoogleMaps.initialize';\n\n document.body.appendChild(script);\n }),\n utilityLibraries: [],\n loadUtilityLibrary: function(path) {\n this.utilityLibraries.push(path);\n },\n _loaded: new ReactiveVar(false),\n loaded: function() {\n return this._loaded.get();\n },\n maps: {},\n _callbacks: {},\n initialize: function() {\n this._loaded.set(true);\n _.each(this.utilityLibraries, function(path) {\n var script = document.createElement('script');\n script.type = 'text/javascript';\n script.src = path;\n\n document.body.appendChild(script);\n });\n },\n _ready: function(name, map) {\n _.each(this._callbacks[name], function(cb) {\n if (_.isFunction(cb))\n cb(map);\n });\n },\n ready: function(name, cb) {\n if (! this._callbacks[name])\n this._callbacks[name] = [];\n // make sure we run the callback only once\n // as the tilesloaded event will also run after initial load\n this._callbacks[name].push(_.once(cb));\n },\n // options: function(options) {\n // var self = this;\n // return function() {\n // if (self.loaded())\n // return options();\n // };\n // },\n get: function(name) {\n return this.maps[name];\n },\n _create: function(name, options) {\n var self = this;\n self.maps[name] = {\n instance: options.instance,\n options: options.options\n };\n\n if (options.type === 'StreetViewPanorama') {\n options.instance.setVisible(true);\n self._ready(name, self.maps[name]);\n } else {\n google.maps.event.addListener(options.instance, 'tilesloaded', function() {\n self._ready(name, self.maps[name]);\n });\n }\n }\n};\n\nTemplate.googleMap.onRendered(function() {\n var self = this;\n self.autorun(function(c) {\n // if the api has loaded\n if (GoogleMaps.loaded()) {\n var data = Template.currentData();\n\n if (! data.options)\n return;\n if (! data.name)\n throw new Meteor.Error(\"GoogleMaps - Missing argument: name\");\n \n var canvas = self.$('.map-canvas').get(0);\n\n // default to Map\n var type = data.type ? data.type : 'Map';\n if (! _.include(supportedTypes, type))\n throw new Meteor.Error(\"GoogleMaps - Invalid type argument: \" + type);\n\n GoogleMaps._create(data.name, {\n type: type,\n instance: new google.maps[type](canvas, data.options),\n options: data.options\n });\n\n c.stop();\n }\n });\n});\n"]}
app/lib/routes.js: GoogleMaps.load({
app/client/templates/rides/create_ride/create_ride.js: if (GoogleMaps.loaded()) {
iron list
accounts-base
accounts-facebook
aldeed:autoform
aldeed:collection2
aldeed:delete-button
ian:accounts-ui-bootstrap-3
iron:router
jeremy:geocomplete
meteor-platform
momentjs:moment
twbs:bootstrap
from meteor-geocomplete.
Unfortunately, I can't reproduce the issue on my end. If you put something up on Github, I'd be happy to take a look at it.
from meteor-geocomplete.
Thanks, I've just created the repo github.com/atzorvas/rideshare
from meteor-geocomplete.
;)
https://github.com/atzorvas/rideshare/blob/master/app/client/head.html#L6
from meteor-geocomplete.
oh thanks, my bad!
from meteor-geocomplete.
Related Issues (20)
- ReferenceError: google is not defined HOT 2
- Why wont the dropdown show HOT 2
- Uncaught TypeError: $(...).geocomplete is not a function on AWS HOT 4
- detailsScope : not picking it up HOT 2
- using geocomplete upon 'modal' HOT 5
- Dropdown doesnt work on ipad HOT 4
- Need to add Flow Router example to readme
- Alternative lists of results HOT 1
- How to get result of input? HOT 1
- Getting to Lat/Lng? HOT 3
- geocode:mapdragged won't fire HOT 3
- MapOptions: Zoom not working HOT 1
- Get current map center HOT 1
- Google Maps API error: ApiNotActivatedMapError HOT 1
- does not load multiple instances of the map with the location set as string HOT 1
- before submit event HOT 2
- How to implement reverse geocoding? HOT 1
- On enter button stop goecode from triggering HOT 1
- I do not work the maps in the new version of Meteor HOT 1
- InvalidValueError: setComponentRestrictions: not an Object HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-geocomplete.