angular-google-maps icon indicating copy to clipboard operation
angular-google-maps copied to clipboard

Which format for markers array?

Open gruberb opened this issue 12 years ago • 11 comments

I have created an array of objects, with title, latitude and longitude. I have it in my scope, everything is defined. But It tells me:

TypeError: Cannot read property 'length' of undefined at MarkersParentModel.ModelsWatcher.didModelsChange http://127.0.0.1:9000/bower_components/angular-google-maps/dist/angular-google-maps.js:662:92

My array looks like this: (screenshot attached). screen shot 2014-02-18 at 20 01 35

How should the objects look like?

gruberb avatar Feb 18 '14 19:02 gruberb

Did you assign coords to coord="'self'" ?

nmccready avatar Feb 18 '14 21:02 nmccready

Yes! screen shot 2014-02-19 at 00 38 10

gruberb avatar Feb 18 '14 23:02 gruberb

No its set incorrectly your passing a string not a binding. It is a key to each model. Coords=" 'self' "

Notice double quote then single quote.

nmccready avatar Feb 18 '14 23:02 nmccready

Oh, thanks....

But still...no marker...something i must doing wrong here... screen shot 2014-02-19 at 00 51 17

gruberb avatar Feb 18 '14 23:02 gruberb

Jsbin and I can answer u w much more speed.

sent from my android device,

Nicholas McCready

Personal Email: [email protected]

Web site: http://codemonkeyseedo.blogspot.com/

Twitter: nmccready

On Feb 18, 2014 6:51 PM, "Bastian Gruber" [email protected] wrote:

Oh, thanks....

But still...no marker...something i must doing wrong here... [image: screen shot 2014-02-19 at 00 51 17]https://f.cloud.github.com/assets/2135077/2201953/978e6d6a-98f7-11e3-8586-6cc7c5053231.png

Reply to this email directly or view it on GitHubhttps://github.com/nlaplante/angular-google-maps/issues/267#issuecomment-35450290 .

nmccready avatar Feb 19 '14 01:02 nmccready

+1 for the tip about " ' ' "

simonh1000 avatar Mar 20 '14 12:03 simonh1000

+1 for the tip! Thanks

oliw avatar Mar 22 '14 15:03 oliw

+1 for the tip @nmccready

spotlmnop avatar Apr 30 '14 10:04 spotlmnop

Just in case anyone is still struggling with this.. It seems to be a bug.

Solution: You must define "events.list" as an empty array and then populate it with the coordinates. So adding scope.events.list = []; should fix the issue.

Here's an example: http://plnkr.co/edit/fieqWTqzKPYwW2xWTgRx?p=preview

anttihavanko avatar May 06 '14 17:05 anttihavanko

@anttihavanko Interesting. That may very well be a bug, but truthfully I wouldn't expect it to work without the declaration outside the timeout (though testing with vanilla angular, it does work in directives and expressions fine) because you're in essence saying "bind to the property that doesn't exist until it exists". Which just seems odd to me.

cthrax avatar May 06 '14 19:05 cthrax

I think this is expected angular binding behavior. If angular doesn't have a reference to compare against, it can't bind to it. Closing, but if anyone disagrees, please re-open with explanation.

cthrax avatar Aug 03 '14 16:08 cthrax