1

Downvote people: Note that this question is n̲o̲t̲ about Google Maps API V3. <google-map> is a GoogleWebComponent that displays a map automagically upon declaration in dom.


var map = document.createElement("google-map");

By only executing this line, it throws an error saying:

Uncaught TypeError: latitude must be a number

I don't even get a chance to set the latitude property.

Is this because I'm creating multiple google-maps (in different dom-modules) within the same page? If not, why is this happening and how do I solve this?


Added

Even doing something like this still yields the same error:

var map = document.createElement("span");
    map.innerHTML = "<google-map latitude='1'></google-map>";
Derek 朕會功夫
  • 92,235
  • 44
  • 185
  • 247
  • In your google map initialization, do you set required parameters? :O – Thibault Bach Jun 12 '15 at 05:47
  • Refer: http://stackoverflow.com/questions/4074520/how-to-display-multiple-google-maps-per-page-with-api-v3 – jasonscript Jun 12 '15 at 05:48
  • @ThibaultBach What do you mean by that? I'm setting the parameters right after that line, however aren't every property optional? ([doc](https://elements.polymer-project.org/elements/google-map)) – Derek 朕會功夫 Jun 12 '15 at 05:49
  • Hum ... can you get your code? Normaly, create multiple map on the same page don't make trouble... – Thibault Bach Jun 12 '15 at 05:54
  • @ThibaultBach That line is literally the only line (in related portion of the code)... – Derek 朕會功夫 Jun 12 '15 at 05:59
  • @Derek朕會功夫, I have been trying to replicate the problem you are experiencing, but to no avail. The code I've been working with is http://pastebin.com/bXaANTHs - perhaps you could provide more context for the code you've provided? It would help to know where this line is, when it is being called, etc. – Adaline Simonian Jun 12 '15 at 09:15
  • @VartanSimonian I have made a demo [here](https://github.com/GoogleWebComponents/google-map/issues/160#issuecomment-111642538). By simply creating a `google-map` element the error is thrown. It shouldn't matter where I call it right? It's just simply creating an dom element. – Derek 朕會功夫 Jun 12 '15 at 23:49
  • @Derek朕會功夫 Looks like you got [your answer](https://github.com/GoogleWebComponents/google-map/issues/160#issuecomment-111644618)! Perhaps try attaching the element to the document DOM first and then set its `innerHTML`? – Adaline Simonian Jun 13 '15 at 00:46
  • @VartanSimonian But how can I attach the element when it already failed at the `createElement` line? Or were you referring to the modifying `innerHTML` trick? – Derek 朕會功夫 Jun 13 '15 at 21:43
  • @Derek朕會功夫 I was referring to the `innerHTML` trick. I was thinking you could try creating a `` tag or something of the sort, but attach it to the document *first* before setting its innerHTML. – Adaline Simonian Jun 13 '15 at 22:56
  • @VartanSimonian I tried that, but that doesn't work even when I make sure the `span` is already attached in the dom. – Derek 朕會功夫 Jun 13 '15 at 23:02
  • 2
    @Derek朕會功夫 Darn. I think we might have to wait for the patch to the issue.. unless someone that knows more stops by and leaves a better answer! – Adaline Simonian Jun 13 '15 at 23:20

0 Answers0