Why can't I get the current location on my map to open Google Streetview window?

5197
13
Jump to solution
01-02-2015 10:05 AM
ChrisSergent
Regular Contributor III

I am trying to get the current location on my. The example that was used originally was for Web Mercator. What do I need to change to get the currentLocation variable to open Google Streetview?

Here is my code: JS Bin - Collaborative JavaScript Debugging  It displays currentLocation as undefined.

0 Kudos
13 Replies
ChrisSergent
Regular Contributor III

Our WKID is 3435 as defined in my setting of custom extent on startup. We use our own imagery and data. We are Illinois State Plane East. The app doesn't work when I put in 3435 for the SR, but it appears to with 4326.

I updated the code to demonstrate.

JS Bin - Collaborative JavaScript Debugging

0 Kudos
HeikoHeijenga
Esri Contributor

Why are you setting the 'outSR' to 3435? You have a point in 3435 and want to project to 4326 to get the lat/lon. Leave outSR to be 4326 and you should be good.

ChrisSergent
Regular Contributor III

Got it. I was just trying to follow the process and now I understand. Thanks for all your help.

by Anonymous User
Not applicable

our map is in web mercator so this is what I did. jQuery handles click handlers, thought I'd leave that there too just as an example.

//Google StreetView tool and handler

        $("#GoogleSVTool").click(function(evt) {

            $("#GoogleSVTool").addClass("SagisHeaderButton");

            //Remove all other tool icon highlights in toolbar

            $("#pictometryTool").removeClass("SagisHeaderButton");

            $("#pan").removeClass("SagisHeaderButton");

            $("#bookMarkTool").removeClass("SagisHeaderButton");

            $("#openPrintButton").removeClass("SagisHeaderButton");

            $("#marketAnalysisTool").removeClass("SagisHeaderButton");

            $("#parcelTool").removeClass("SagisHeaderButton");

            $("#identifyTool").removeClass("SagisHeaderButton");

            $("#drawTool").removeClass("SagisHeaderButton");

            $("#zoomout").removeClass("SagisHeaderButton");

            $("#zoomin").removeClass("SagisHeaderButton");

            //handlers

            if (handlerStreetView) {

                handlerStreetView.remove();

                handlerStreetView = null;

                $("#GoogleSVTool").removeClass("SagisHeaderButton");

            } else {

                //first remove other handlers..

                if (eventHandlerIdentify != null) {

                    eventHandlerIdentify.remove();

                }

                navToolbar.deactivate();

                if (maponclick != null) {

                    maponclick.remove();

                };

                //activate Streetview handler

                handlerStreetView = map.on("click", function(evt) {

                    if (maponclick != null) {

                        maponclick.remove();

                    };

                    if (eventHandlerIdentify != null) {

                        eventHandlerIdentify.remove();

                    }

                    navToolbar.deactivate();

                    //

                    var pt = esri.geometry.webMercatorToGeographic(evt.mapPoint);

                    var url = "http://maps.google.com/maps?q=Your+Sign+Location+in+Street+View@" + pt.x + "," + pt.y + "&cbll=" + pt.y + "," + pt.x + "&layer=c";

                    window.open(url);

                                  });

            };

        });

        //Google StreetView tool and handler

Got it from your earlier thread How do I add Google Street View to my ArcGIS API for JavaScript apps?. Thanks to everyone here! Love the team spirit. Couldn't have gotten our viewer done without support here.  the JS API is really shaping up! 

0 Kudos