|
stoops posted:64799 358.500 89.500 800.325 271.256 66.543 Does one pixel position equal one line of text, or is it possible that it has more? How do the two columns correspond to the x/y coordinates of the image?
|
# ? May 9, 2014 19:48 |
|
|
# ? May 16, 2024 07:04 |
|
obstipator posted:
Yes it does. Awesome thanks, I'll try that. KARMA! posted:Does one pixel position equal one line of text, or is it possible that it has more? How do the two columns correspond to the x/y coordinates of the image? Yes, one pixel position equals only one line of text. The x/y i'm passing are the lon(second column) and lat(3rd column)
|
# ? May 9, 2014 20:20 |
|
stoops posted:I have a textfile with lines like this: (about 65000 lines, 6 columns) JavaScript code:
I.e. the first line is split_lines[0]. The second column of the first line is split_lines[0][1]. Wheany fucked around with this message at 23:01 on May 9, 2014 |
# ? May 9, 2014 22:59 |
|
Okay and I only now realized that I didn't really answer your question.
|
# ? May 9, 2014 23:07 |
|
stoops posted:Yes it does. Awesome thanks, I'll try that. JavaScript code:
Any questions?
|
# ? May 10, 2014 02:40 |
|
Having trouble returning something from an inline function. I'm following this guide on pulling elevation data from Google maps via APIv3. The example doesn't return anything. I'd like to, but can't using the inline function example. I can print the correct data, but not return it. If I try to make it a non-inline function, 'results' can't be found. I read on Stack overflow to add an extra () after the inline function to make it work, but get 'uncaught typerror: undefined is not a function' when I try. JavaScript code:
Dominoes fucked around with this message at 14:10 on May 11, 2014 |
# ? May 11, 2014 12:25 |
|
Dominoes posted:Having trouble returning something from an inline function. I'm following this guide on pulling elevation data from Google maps via APIv3. The example doesn't return anything. I'd like to, but can't using the inline function example. I can print the correct data, but not return it.
|
# ? May 11, 2014 14:06 |
|
Wheany posted:You have some weird bracing in your code. The "if (status ==" line's opening curly brace is closed after the "return elevation" row, but you never close the function(results, status) opening brace. Looking at the examples I read that included the extra (), they had the return/variable assignment directly before 'function', which may be why that fix doesn't work. I can't do that here, since there's a bit of google code that needs to go there instead. I feel like there should just be a method to google latLng instances, so you could just do location.elevation(). Instead it's a mess.
|
# ? May 11, 2014 14:12 |
|
Well, if I reformat your code like this:JavaScript code:
I noticed that the original "elevation" in your code was a global variable and that its value is either whatever its value was before (or undefined if it has been never set before) or the value of results[0].elevation, if status == google.maps.ElevationStatus.OK I renamed that variable to cb_elevation and made it local to the inner function and added a new local elevation variable to the outer function.
|
# ? May 11, 2014 14:23 |
|
Dominoes posted:Having trouble returning something from an inline function. I'm following this guide on pulling elevation data from Google maps via APIv3. The example doesn't return anything. I'd like to, but can't using the inline function example. I can print the correct data, but not return it. Wait, is "elevation" what you want to return from getElevation? If so I think you're confused at a few levels here. The function you pass to getElevationForLocations, is, as far as I can tell, supposed to be a callback function. That means the request is sent off, and when the answer is found your callback is called. The point here is that the result is asynchronous, you can't just get the answer back and return it from your function getElevation. Secondly, even if that were not the case, what you're trying to do doesn't make any sense. getElevationForLocations is a function that takes a function. Why do you think that, by returning "elevation" in the passed function, getElevationForLocations will itself return "elevation"? There's no reason for that to happen. getElevationForLocations like returns either nothing or some sort of status, and that is what you're returning from getElevation Edit: Read this quote:Accessing the Elevation service is asynchronous, since the Google Maps API needs to make a call to an external server. For that reason, you need to pass a callback method to execute upon completion of the request. This callback method should process the result(s). Note that the Elevation service returns a status code (ElevationStatus) and an array of separate ElevationResult objects. HappyHippo fucked around with this message at 16:10 on May 11, 2014 |
# ? May 11, 2014 16:06 |
|
Wheany posted:Well, if I reformat your code like this: HappyHippo posted:Wait, is "elevation" what you want to return from getElevation? If so I think you're confused at a few levels here. Dominoes fucked around with this message at 17:13 on May 11, 2014 |
# ? May 11, 2014 16:59 |
|
Dominoes posted:I have a working, but messy solution: Wedge the rest of my relevant code into the callback function instead of trying to split into multiple clean, reusable functions. Why can't you call those reusable functions from your callback? (Google's docs are somewhat unhelpful in saying "Elevation service returns a status code (ElevationStatus) and an array of separate ElevationResult objects", when it's really not a return value. It makes sense once you're used to the async callback pattern, but I think would be better as "Elevation service invokes the callback with a status code …".)
|
# ? May 11, 2014 17:43 |
|
Subjunctive posted:Why can't you call those reusable functions from your callback?
|
# ? May 11, 2014 17:55 |
|
Dominoes posted:Guess I could! I know you post in the Python thread a lot, so I'll point this out: JS is similar to Python in a lot of ways and you can write a lot of stuff in pretty much the same way, but you'll really need to wrap your head around the idea that a lot of stuff you'll be doing with JS is asynchronous. Callbacks are a way of life.
|
# ? May 11, 2014 20:49 |
|
Thermopyle posted:I know you post in the Python thread a lot, so I'll point this out: JS is similar to Python in a lot of ways and you can write a lot of stuff in pretty much the same way, but you'll really need to wrap your head around the idea that a lot of stuff you'll be doing with JS is asynchronous. Callbacks are a way of life. Speaking of which: Is exception handling in JS used only for problems? I got this impression after reading several pages describing how empty catch statements are never a good idea. Here's an example. The assumption seems to be that try/catch is only used when something goes wrong, and isn't used for expected behaviors. 'Easier to ask for forgiveness than permission' and duck-typing in Python are used all the time. Is this just an issue of different philosophies driving the guidelines I've read? Dominoes fucked around with this message at 22:56 on May 13, 2014 |
# ? May 11, 2014 23:00 |
|
KARMA! posted:
Thanks (and you too, obstipator). I ended up using this, but now my textfile data has changed, and I'm not sure how to go about it. Before, my textfile would be like this: code:
code:
1 0.500 -89.500 712.256 88.743 -66.551 I tried to do a, data.split ("sector # elon elat theory ra dec"), but that gives me an extra line at the very top before my real data begins, so it reads like this: code:
|
# ? May 13, 2014 21:06 |
|
stoops posted:Any way to make my data start without the extra line? Thanks for the help. You could just slice() the split array: code:
You might want to check your first row to make sure it's not header data before you slice it up, but I'm not sure if that's going to be a problem based on what you posted.
|
# ? May 13, 2014 22:19 |
|
Could put a newline in the split string, then it would be consumed.
|
# ? May 13, 2014 22:42 |
|
Dominoes posted:A lot of what I've done on this project is adapting existing python code, so users can manipulate Gmaps live instead of having to go back to the django page and resubmit. It's been a smooth transition so far. There's been a bit of rewriting shortcuts the long way while I figure out equivalent ones in js. I'm taking a few things I like from Python that are optional, but nonstandard, like == instead of === and no semicolons. As for semicolons, I'd also strongly recommend just using them. If you really don't like them, you should (must) prefix lines starting with ([ with semicolons, which in my opinion looks worse. Dominoes posted:Speaking of which: Is exception handling in JS used only for problems? I got this impression after reading several pages describing how empty catch statements are never a good idea. Here's an example. The assumption seems to be that try/catch is only used when something goes wrong, and isn't used for expected behaviors. 'Easier to ask for forgiveness than permission' and duck-typing in Python are used all the time. Is this just an issue of different philosophies driving the guidelines I've read? I'd say Javascript is more in the look before you leap land.
|
# ? May 14, 2014 11:21 |
|
On a web application accessed from ipad safari I am using the jQuery to perform autocomplete. The autocomplete is working however I am unable to scroll through the items. I have attempted to accomplish this via CSS however it does not seem to work. I would like to use javascript to add scroll to the autocomplete, however it seems to not work. Was attempting to use something similar to below to add scroll, but was unsuccessful. code:
|
# ? May 15, 2014 20:07 |
|
Looking for advice on regex in Javascript. I have several different regegexes, and I've been trying to filter the valid one(s) by checking if the result exists. However, Even the invalid ones return a valid array: Just with undefined values on the parts that don't match. ie: JavaScript code:
JavaScript code:
|
# ? May 19, 2014 09:53 |
|
Dominoes posted:
What are you matching against?
|
# ? May 19, 2014 10:10 |
|
Wheany posted:What are you matching against?
|
# ? May 19, 2014 10:15 |
|
When you RegExp your strings, is it expected that your coordinates will always return non-undefined values for the regex matches, or is it OK for the number of "undefined" returns values to fluctuate? For instance, if you jam in "N32.1234" you might get [32, 1234, undefined] but if I jam in "N32" I get [32, undefined, undefined]. Is the second example still a valid lat/lng? I can't offer you anything native to make your life easier, but LoDash has a few functions you can use. code:
|
# ? May 19, 2014 14:31 |
|
Dominoes posted:User-input of lat/lon coordinates in various formats. Ok, please post some valid examples, and possibly some invalid examples. It's impossible to go backwards from the posted regexes, because they might have some errors. Also because regexes are a write-only language. For experimenting, I have used The Regex Coach http://www.weitz.de/regex-coach/
|
# ? May 19, 2014 15:33 |
|
If you're accepting user input for lat/longs you might want to rethink your system. Is your audience technical enough that they have to input exact coordinates? If not, maybe you should geocode addresses and not worry about regexing coordinates. If so, you might want to reverse geocode input coordinates and see if your service returns a valid location.
|
# ? May 19, 2014 15:47 |
|
Dominoes posted:Looking for advice on regex in Javascript. I have several different regegexes, and I've been trying to filter the valid one(s) by checking if the result exists. However, Even the invalid ones return a valid array: Just with undefined values on the parts that don't match. Use the method, 'test' for validity: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test
|
# ? May 19, 2014 17:44 |
|
Strong Sauce posted:Use the method, 'test' for validity: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test If exec() returns a non-null result then test() returns true.
|
# ? May 19, 2014 18:03 |
I'm running into some JS errors after incorporating dropzone.js into my app. Everything works fine in dev mode (separate & unminified assets) but after I do a real build (JS assets are combined & minified using uglifyjs) I run into "undefined is not a function". So I'm assuming it's something to do with the combine/minify step but I'm having a hard time narrowing it down further. edit: I added a semicolon to the end of the dropzone.js file and it seems to have fixed the issue...but surely somebody else would have run into that issue if the problem was in fact caused by dropzone.js. So I'm not entirely convinced I have the correct fix, if anybody has some advice for me. fletcher fucked around with this message at 03:06 on May 20, 2014 |
|
# ? May 20, 2014 02:05 |
^^ Looks like it was in fact a bug in the dropzone library: https://github.com/enyo/dropzone/issues/589
|
|
# ? May 21, 2014 19:19 |
|
v1nce posted:When you RegExp your strings, is it expected that your coordinates will always return non-undefined values for the regex matches, or is it OK for the number of "undefined" returns values to fluctuate? Wheany posted:Ok, please post some valid examples, and possibly some invalid examples. Blinkz0rz posted:If you're accepting user input for lat/longs you might want to rethink your system. Strong Sauce posted:Use the method, 'test' for validity: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test Wheany posted:If exec() returns a non-null result then test() returns true. Thanks dudes! Got it sorted. Your questions prompted me to go back and look at the regexes - they were kind of a mess. The direct solution to my question was probably to add ^ and $ to the regexes, which would reject incomplete matches. I ended up redoing the regexes in a modular way. The audience is somewhat technical, and would probably stick to one main format. However, I don't want to be a dick and throw an error if they used a hyphen instead of a space, didn't use enough leading 0s, had a degree but not minute etc. Current implementation: JavaScript code:
Dominoes fucked around with this message at 00:17 on May 23, 2014 |
# ? May 22, 2014 19:13 |
|
Not necessarily a javascript question.. Not sure where to post this. I have built a styled infoBox using the InfoBox plugin for google maps. As part of the infobox there are two columns which are positioned using relative positioning and placed left or right using float:left, or float:right. Strangely when I click on some of the markers and popup the same infobox the right column is sometimes pushed down, even though its using the same exact CSS. See the below images. http://s24.postimg.org/60olyoa2t/image.jpg http://s24.postimg.org/ky1odfcp1/image.jpg Infobox creation code:
|
# ? May 22, 2014 19:47 |
|
If you're using a 600px-wide fixed size box anyway, you could just set CSS code:
|
# ? May 22, 2014 20:06 |
|
Are there any simple JS libraries that include common convenience functions/methods that are omitted from JS? Ie: JavaScript code:
Dominoes fucked around with this message at 15:08 on May 25, 2014 |
# ? May 22, 2014 23:11 |
|
Dominoes posted:Are there any simple JS libraries that include common convenience functions/methods that are omitted from JS? Underscore, lodash. e: Well, okay, those don't include conversion between degrees and radians, but I don't actually think those as something needing a library necessarily. Also sort is a native function in arrays. e2: and even your example is just "return anArray.sort();" Now I'm completely lost on what you even want. Wheany fucked around with this message at 11:35 on May 23, 2014 |
# ? May 23, 2014 11:30 |
|
There's always php.js! Simply hand pick the PHP functions you want from their semi-impenetrable github repo and you can include them in your project for fun and profit. There's a wealth of maths functions for you to take advantage of. I'll be honest, I was joking when I started down this road, but it actually sound like it's what you're after. poo poo.
|
# ? May 23, 2014 13:18 |
|
Wheany posted:e2: and even your example is just "return anArray.sort();" Now I'm completely lost on what you even want. No, his version has "sorted", a which compares elements as numbers, instead of Array.prototype.sort sorting elements as strings. Obvious from the name, no?
|
# ? May 23, 2014 14:12 |
|
I don't think I've ever just wanted to sort an array of numbers. I usually need to sort based on some property or something. Honestly with the library thing, I don't think it's all that necessary. I just add them as you need them. They aren't that complicated to write.
|
# ? May 23, 2014 16:06 |
|
Looking for thoughts on 'for in' loops in javascript, and this Stack Overlow question on the topic. The accepted answer is that JavaScript code:
The way I'm looking at it, this: JavaScript code:
Dominoes fucked around with this message at 15:09 on May 25, 2014 |
# ? May 25, 2014 14:59 |
|
|
# ? May 16, 2024 07:04 |
|
I don't get how sparse arrays are an argument for using a traditional for over for ... in, seeing how for ... in actually handles them correctly? (OTOH, I wonder how well modern JS implementations can compile for ... in; it is a lot harder to execute efficiently since 'i' is semantically a string on every iteration).
|
# ? May 25, 2014 15:30 |