Last active
August 29, 2015 14:04
-
-
Save DavidSpriggs/e63dd758a3c87f0611b3 to your computer and use it in GitHub Desktop.
streetview pro4js code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getStreetView: function(mapPoint) { | |
// location chosen by clicking the left panel button or by using streetview widget | |
dojo.style(this.noStreetViewResults, 'display', 'none'); | |
dojo.style(this.loadingStreetView, 'display', 'inline-block'); | |
if (mapPoint.spatialReference.wkid !== 4326) { | |
var coordinatesToProject = { | |
x: mapPoint.x, | |
y: mapPoint.y | |
}; | |
var fromProjection = this.wkt_26852; | |
var toProjection = this.wkt_4326; | |
var gcsPointCoords = proj4(fromProjection, toProjection, coordinatesToProject); | |
this.getPanoramaLocation(gcsPointCoords); | |
} else { | |
this.getPanoramaLocation(mapPoint); | |
} | |
}, | |
setPlaceMarkerPosition: function() { | |
if (!this.placeMarker || this.pointGraphics.graphics.length === 0) { | |
this.placeMarker = new esri.Graphic(); | |
// Add graphic to the map | |
this.pointGraphics.add(this.placeMarker); | |
} | |
// get the new lat/long from streetview | |
var panoPosition = this.panorama.getPosition(); | |
var positionLat = panoPosition.lat(); | |
var positionLong = panoPosition.lng(); | |
// Make sure they are numbers | |
if (!isNaN(positionLat) && !isNaN(positionLong)) { | |
// convert from 4326 to 26852 | |
var fromProjection = this.wkt_4326; | |
var toProjection = this.wkt_26852; | |
var coordinatesToProject = { | |
x: positionLong, | |
y: positionLat, | |
}; | |
var pcsPointCoords = proj4(fromProjection, toProjection, coordinatesToProject); | |
var pcsPoint = new esri.geometry.Point(pcsPointCoords.x, pcsPointCoords.y, new esri.SpatialReference({ | |
wkid: 26852 | |
})); | |
// change point position on the map | |
this.placeMarker.setGeometry(pcsPoint); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment