0
votes

I'm working on a project where i have to use dojo (i'm doing a custom widget) and the google map api (v3)

For some technical reason, i have to include the google map api through my js file and not through my html file, so i can't use

<script type='text/javascript' src='http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places'></script>

The load have to be done synchronously.

I've tried some things, first adding the script using

document.write("<script type='text/javascript' src='http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places'></script>");

But that's not working, i get a blank page instead, using firebug i can see that the panel "Network" is clearing and the page make an infinite loading of google map api script.

I think i can't do it using dojo.io.script (which allow to make cross domain request), because we can't make synchronous request with dojo.io.script

Any help will be appreciated ;)

2
can you take all of the custom widget code to justpaste.it ? - OammieR
The widgets code will not help, but someone with a similar problem (stackoverflow.com/questions/7438854/…) posted something here : jsfiddle.net/sKNmS, that's the same things i'm trying to do with dojo.io.script - Natha

2 Answers

1
votes

Well, solution was to use google map callback :

var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places&callback=mapLoaded";
document.body.appendChild(script);

Then make the function "mapLoaded" which execute the code

Thanks for those who taked time to answer me

0
votes

You should still be able to use dojo.io.script. It does not have to be synchronous. The maps API takes a c