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.
See Create a Map
Problem is now however that a browser's popup-blocker will kick in. This is because the new window is opened in an async callback.
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) {
//
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);
});
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!
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.
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
Not sure I follow, can you elaborate?
One last question. My projection is 3435. It doesn't work when I replace 4326 for this. Will this be an issue? It seems to be accurate though.
Ah, I see... You're not using webmercator
Then you would need to use the Geometry service to project to lat/long.
Chrome DevTools is pretty clear:
So, require esri/geometry/webMercatorUtils
That helped but I need to replace the line var theLatLongGeom = webMercatorUtils.webMercatorToGeographic(theLocation); I'm not using webMercator. What should that be changed to?
Here is my updated code:JS Bin - Collaborative JavaScript Debugging
You forgot to require esri/geometry/Point
esri/geometry/Point
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.