Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading Map without loadMapApi() #235

Open
aouskaroui opened this issue Dec 25, 2016 · 5 comments
Open

Loading Map without loadMapApi() #235

aouskaroui opened this issue Dec 25, 2016 · 5 comments

Comments

@aouskaroui
Copy link

Hello everyone,
Thank you for this great Gwt library !
I'm a beginner in GWT and I'm having some questions:
Is it possible to run the Map without calling the loadMapApi() method ?
Actually, when I call loadMapApi(), the Map loads fine for a first sight but it doesn't provide any interaction. It means that all buttons, markers or whatever I put on it are shown in the map but they don't really work !
Otherwise, when I just call the draw() method, without calling loadMapApi(), the map loads fine and all buttons, markers are interacting. The problem is when I want to add the AutoComplete text box. I get this error "Cannot read property 'Autocomplete' of undefined".
However, when I call loadMapApi(), I don't get that error. The map loads fine with the Autocomplete box on it, but there is no interaction. I just get a good looking frozen Map ! I don't know if there is a problem with the Thread or something. I just copied the provided code with no change.

@dpdearing
Copy link

I'm also having a problem with using LoadApi.go()...if that's what you mean (although not the same problem that you describe). My issue is that the map does not appear when first loaded and doesn't show up until resizing the browser window. Anyway, I'll share what seems to work for me.

I've found that I can directly load the Maps API by including the <script> tag from the Google Maps API tutorial in my html page. I'm not sure if there's a race condition with determining if onModuleLoad happens before the script finishes loading. Might need to leave out the async attribute.

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"
    async defer></script>

@aouskaroui
Copy link
Author

Hello,
I had the same problem once. I thought it was something with the GWT panels or the resize functions, so I tried many kinds of panels and the MapWidget.triggerResize() method but nothing worked for me.
Finally, I figured out that the map needs some time to load (until getting the Ajax callbacks answers) so I put the draw() method within a Timer instance and the problem was resolved.
Here is a snap of the way I did it:
Timer timer = new Timer() {
@OverRide
public void run() {
draw();
setContent(mapWidget);
}
};
timer.schedule(4000);
}

@treethinker
Copy link

treethinker commented Jan 16, 2017 via email

@aouskaroui
Copy link
Author

Okay. If you're using the loadMapApi() method, you just have to call it inside the Timer run() like I did, but instead the draw() method.
Please let me know if it fix the issue...

@aouskaroui
Copy link
Author

Hello again, actually there are some differences between testing on local and on a web server. For me, MapWidget.triggerResize() resolved the problem described by "dpdearing" above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants