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!
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
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.