Comments (7)
I noticed this problem as well when we were using this project internally in our own ReactJS application.
Instead of using:
import SnazzyInfoWindow from 'snazzy-info-window';
Use the following:
let SnazzyInfoWindow = require('snazzy-info-window');
The reason the bug exists is because of this line right here:
export default class SnazzyInfoWindow extends google.maps.OverlayView {
We might be able to resolve this issue by adding a wrapper object around SnazzyInfoWindow which checks for the existence of google before trying to create the subclass.
Thanks for the feedback. Hopefully the above solution will work for you in the mean time.
from snazzy-info-window.
Thanks, the above solution works like a charm. And thanks for responding so fast!
One more question, how do I import the css?
from snazzy-info-window.
You can import the css in your project with the following snippet:
import 'snazzy-info-window/dist/snazzy-info-window.min.css';
Note to self:
Add documentation about imports when fixing this bug.
from snazzy-info-window.
Any updates on this?
I'm using the following as well:
let SnazzyInfoWindow = require('snazzy-info-window');
but Uncaught ReferenceError: google is not defined
still appears occasionally and stops all other scripts
from snazzy-info-window.
Thanks once again! You're awesome!
from snazzy-info-window.
@goldfinch where exactly do you place that line in the code?
I was having literally the same issue after just replacing import
to require
statements in the top of my file. But that changes nothing in general.
But there is one benefit - you are allowed to use require
statements anywhere in your file.
I used <script src=https://maps.googleapis.com/maps/api/js?key=${apiKey}&callback=initMap async defer'></script>
and then in my JS:
window.initMap = function() {
const SnazzyInfoWindow = require('snazzy-info-window');
new SnazzyInfoWindow({ /* ... */ });
}
P.S. For this case, const
is more suitable over let
.
from snazzy-info-window.
@pttsky sorry for the late response,
I solved this issue using callback, to make sure that the google library loads first, eg:
<script>
window.initSnazzy = function(){
let SnazzyInfoWindow = require('snazzy-info-window');
// ....
};
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=API_KEY&libraries=places&callback=initSnazzy"></script>
from snazzy-info-window.
Related Issues (20)
- All plugins and embeds are broken HOT 1
- <img> tag doesn't work inside window string
- Options for width and height
- Centering info window with a dynamic info box size
- Close multiple windows HOT 4
- The ability to update HTML in the online "map builder" interface
- Click listener supported? HOT 1
- .getMap is not a function HOT 5
- complex-styles Broken with latest Upgrade HOT 1
- agm-snazzy-info-window width can not be set with maps api v3.32
- agm-snazzy-info-window responsive size broken
- is there a way to detect which markers are displayed in a particular cluster already opened and inside the view only?
- Left/right placement reversed
- Is it possible to close window on the second click on a marker?
- Where do I find embed code, not iframe code?
- How To Use In React?
- Usage with agm-direction
- Info window opening far away from the marker HOT 2
- How to install on WP HOT 1
- Unable to add custom style in CSS
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 snazzy-info-window.