How will I be able to drop the pegman programmatically on a point on a map. I have a "click" event of the map. I need to drop the pegman on the coordinates where it was clicked.
Asked
Active
Viewed 375 times
0
-
Just a quick thought. Could you set the location of the panorama to that click position. If the two are tied together then that should place the pegman on the map. – Rafe Mar 07 '13 at 16:10
-
@Rafe Yes i have set the location of panorma to that click position but it is not placing the pegman on the map. – coderslay Mar 07 '13 at 16:16
-
Have you tied the two together with map.setStreetView(panorama); Showing your code might help – Rafe Mar 07 '13 at 16:19
-
Hey i got it. I removed streetViewControl: false and then it was working... Your thought gave me an idea. Thank you :D – coderslay Mar 07 '13 at 16:22
-
I had that same problem. The map I am working on I hide the controls and show them on mouseover. I had to show streetViewControl, move the map and then hide it again. – Rafe Mar 07 '13 at 16:24
-
In my condition. I had to remove the pegman from the map and draw an icon similar to pegman on the map on click of a location. Please Post your answer so that i will accept...:) – coderslay Mar 07 '13 at 16:26
2 Answers
1
If you want the pegman to appear on a map, you need to enable the streetview controller.
It can be disabled again after if you wish.
Check comments on original post for more information.

Rafe
- 793
- 6
- 15
0
Pegman can be placed by application on a map, when the map and panorama containers are separated and panorama is associated to the map.
eg.:
HTML
<div id="mapContainer"></div> <div id="svpContainer"></div>
JavaScript
var mapElement = document.getElementById('mapContainer'); var svpElement = document.getElementById('svpContainer'); var map = new google.maps.Map(mapElement, {...}); var svp = new google.maps.StreetViewPanorama(svpElement, { position: {lat: svpLat, lng: svpLng}, visible: true, ... }); map.setStreetView(svp);
The trick is, that svpContainer can be hidden as HTML Element by CSS
#svpContainer { display: none; ... }
or
JavaScript
document.svpElement.hidden=true
or whatever (instead of svp being switched off from within itself [funcionality of svp option enableCloseButton: true] nor using programmically svp option visible:true/false) !
Svp option "visible" is the clue. It must be "true", to keep Pegman on the map.
In result the Pegman is on the map in the choosen by you place:
svp.setPosition({lat: ...,lng: ...});
Go mad :D

Marek Wysmułek
- 786
- 6
- 6