I am working on a simple app that lets you click on the map and open a new browser window showing oblique imagery at that point. It takes the point coordinates, passes them to a url and opens a new browser page using the created url. I think I am close, but with what I have now, when the page loads and you click on the map I get an error saying, "Cannot read property 'y' of undefined". However if I click again my function works and the page opens properly. If you continue to fire the function it continues to work. It gets messed up with only the first attempt. Any ideas???
Here is the app: JSFiddle
Solved! Go to Solution.
Hi Ryan,
In your fiddle move line 92 to after line 89. Like below:
gsvc.project([point], outSR, function (projectedPoints) {
pt = projectedPoints[0];
window.open("http://fiscalims.summitoh.net/GVViewer/ViewerAX.htm?res=2&lat=" + pt.y.toFixed(5) + "&lon=" + pt.x.toFixed(5));
});
What's happening is,
your window.open will always get executed before project is completed. For the first time it'll fail because pt would be null, from next time on it'll use the X and Y from your previous project operation.
Hi Ryan,
In your fiddle move line 92 to after line 89. Like below:
gsvc.project([point], outSR, function (projectedPoints) {
pt = projectedPoints[0];
window.open("http://fiscalims.summitoh.net/GVViewer/ViewerAX.htm?res=2&lat=" + pt.y.toFixed(5) + "&lon=" + pt.x.toFixed(5));
});
What's happening is,
your window.open will always get executed before project is completed. For the first time it'll fail because pt would be null, from next time on it'll use the X and Y from your previous project operation.
Awesome. That was it. I appreciate the help as well as the explanation as to what was going on.
Thank you!
Hi Riyas,
You have answered my initial question, but I have stumbled upon another problem with my app and rather than start a new discussion I thought it would be appropriate to reply in this one.
What I am trying to do now is create a simple checkbox that will enable or disable the openGeovista function on click. Like with the first issue, I am close. Right now when the page loads, the box is checked but the function won't fire. When I toggle the checkbox off, then back on again, the function works. Here is the fiddle - JSFiddle. I have to be missing something really small. Any help is much appreciated!
Hi Ryan,
Two corrections in your code.
map.on("load", mapReady);
Hi Riyas!
Sorry for the delay in my response. That was it! I knew it was something small that I was missing!
Thanks so much for your help, again!
Ryan