1

I forked an interesting map application with sidebar information for a different purpose.

However, I noticed today that every time I go past 10 parklets from this repository: http://mick.github.io/jekyllmap/ or (https://github.com/mick/jekyllmap), it starts getting slightly wonky.

I've poked around in mapping.js from assets/js to see where the problem may be coming from.

I can't figure out where it is coming from.

The markers in my application, when past 10 parklets, the markers get stuck, don't change color, or point to the wrong info.

Any advice on how to get this to work for about 26 properties?

Thanks!

ps.to make it clear, the links above are not my github accounts. figured it would be simpler to link to the original account from which i forked from.

user273072545345
  • 1,536
  • 2
  • 27
  • 57

1 Answers1

2

mapping.js line 7

var point = parseInt($(this).attr('data-target').substr(1));

or

var point = parseInt($(this).attr('data-target').substring(1));

and not

var point = parseInt($(this).attr('data-target').substr(1,1));

Edit:

Sorry no need to use substring instead of substr. Just delete second parameter.

As said in substr doc : str.substr(start[, length])

If you set the second parameter .substr(1,1) The string return is from character 1 (the second in the string as the index starts at 0) for a length of 1. For #1 and #10 or #11 .substr(1,1) returns 1.

If you don't pass the second parameter .substr(1) you get the original string from character string[0] to the end of the string.

  • For #1 .substr(1) returns 1.
  • For #100 .substr(1) returns 100.
  • For #19298298928 .substr(1) returns 19298298928.

And if you're curious difference between substr and substring is here

Community
  • 1
  • 1
David Jacquel
  • 51,670
  • 6
  • 121
  • 147
  • thanks! Appreciate it. Hope you don't mind me asking you to explain what the original one was returning, and how you understood how to change it? No need to explain, but only asking since I'd like to understand how to modify any future stuff. – user273072545345 Jul 03 '14 at 17:51
  • Hello Mick, I've edited my answer to explain the why of the bug. – David Jacquel Jul 03 '14 at 19:59
  • thanks! Just to clarify, I'm not Mick. I just linked to the original github account from which I forked from because I knew the problem was originating from it. – user273072545345 Jul 03 '14 at 22:15
  • so, to sum up your answer, by the act of setting the second parameter, it screwed the numbers? #19298298928 would have become #19298298921 instead? Is that what you're saying? – user273072545345 Jul 03 '14 at 22:25
  • No #19298298928.substr(1,1) = 1 Just as #1.substr(1,1) = 1 – David Jacquel Jul 03 '14 at 22:31