fish_r
fish_r

Reputation: 697

Google Maps API - Move Control position whilst inside streetview?

Does anyone know how i would move the pan/zoom control position of google maps whilst inside streetview?

I can position the controls to the right side on normal map view, but when streetview is activated the pan control and the zoom buttons switch over to the left hand side?

How would i go about telling these to position to the right whilst streetview is active?

Thanks!

Upvotes: 0

Views: 1167

Answers (2)

byvalentino
byvalentino

Reputation: 11

I've tested the following code and it worked for me

    map.get('streetView').setOptions({
             panControlOptions:  map.get('panControlOptions'),
             zoomControlOptions: map.get('zoomControlOptions')});

Upvotes: 1

Dr.Molle
Dr.Molle

Reputation: 117354

the streetView has it's own control-options which will not be inherited from the map.

You must explicitly set these control-options for the streetView:

<script>
function initialize() {
    var mapOptions = {
    center: new google.maps.LatLng(42.345573,-71.098326),
    zoom: 14,
    panControlOptions:{
      position:google.maps.ControlPosition.RIGHT_TOP
    },
    zoomControlOptions:{
      position:google.maps.ControlPosition.RIGHT_TOP
    }
  };
  var map = new google.maps.Map(
      document.getElementById('map-canvas'), mapOptions);

  //apply the map-settings for panControl and zoomControl to the streetView:
  map.get('streetView')
    .setOptions({panControlOptions:  map.get('panControlOptions'),
                 zoomControlOptions: map.get('zoomControlOptions')});
}

google.maps.event.addDomListener(window, 'load', initialize);

</script>
<div id="map-canvas" style="width: 400px; height: 500px"></div>

Upvotes: 0

Related Questions