last day (17 days later) » 

4:09 PM
1
A: Finding Location / Coordinates in Dart

Günter ZöchbauerAccording to this bug report (https://code.google.com/p/dart/issues/detail?id=15866) it is not supported. You need to build to JavaScript and run in Chrome to get the location. When you use pub serve (as recent DartEditor versions do) you can open the same URL in Chrome you are using in Dartium.

 
I understand, but how would you find the location in the first place, what is the code for it?
 
stackoverflow.com/questions/13394124 Add a comment if it doesn't work. The question is a bit old. This question/answer seems to indicat that it works in Dartium when you provide the API keys stackoverflow.com/questions/20824595
 
When I use that code, I get an error saying that there is not meant to be any arguments, so when I get rid of the arguments and put it to a string it outputs: Instance of '_Future<Geoposition>' Help?
 
Can you please add the code you used to your question and point out at which statement you get the error.
 
I was using the code from the link that you gave me, and the statement is: window.navigator.geolocation.getCurrentPosition((Geoposition position) { window.alert(position.coords.latitude.toString()); });
 
4:09 PM
I added a second link to this comment, the code there seems to be more current. Please try this one.
 
When using that, I get this alerted: Instance of 'Geoposition'
 
Hello
Thanks for helping out by the way
Got any suggestions?
 
this means you get a value of type Geoposition back. That looks fine.
You should change your code so that `window.alert(...)` is in it's own line. Then you can set a breakpoint and examine what properties the value (type `Geoposition`) has or you navigate to the `Geoposition` code (Ctrl+click) and look there what properties it offers.
 
so window.alert was already on its own line
 
4:15 PM
ok, I can't see this because the comment removes the line breaks
can you set a breakpoint at this line and is the breakpoint hit?
 
do I go in debug mode then? I hardly use debug mode
I'm not sure how to use breakpoints in Dart Editor
 
sorry, this is a native object
`position.coords.latitude`,
`position.coords.longitude`
should give you the values
where position is the value you get passed
 
how do you check values
 
in the debugger?
 
yes
well
I dont think there is a debugger in dart editor
 
4:22 PM
of course there is
ctrl+shift+b sets/removes a breakpoint
when you launch Dartium from DartEditor the breakpoint is hit
 
ok
so now how do I check the value
?
Im not sure how to do it
 
Did you set the breakpoint and launch the page in Dartium?
When the breakpoint is hit the debugger shows current variables and their fields.
 
4:39 PM
I looked again and I think the code from the second link should work
http://stackoverflow.com/questions/20824595

window.navigator
.geolocation.getCurrentPosition()
..then((pos) {

window.alert(pos.toString());
})
sorry instead of `pos.toString` you should use
`window.alert(pos.coords.latitude.toString());`
or
`window.alert(pos.coords.longitude.toString());`
 
5:29 PM
sorry I was doing some school work, thanks for the reply, I will try that solution in a second. How do you know so much about dart. You are awesome for answering all my dart questions. I wonder if I could keep in contact with you some how.
 
 
3 hours later…
8:42 PM
@GünterZöchbauer Quick question, how would you get an onClick event working?
for an image not a button
I really need help
got any idea why this might not work:
var img = (querySelectorAll('img') as HtmlElement);
img.onClick.listen((e) {
window.alert("works");
});
 

  last day (17 days later) »