标记没有出现在GMSPanoramaView上

时间:2016-05-18 16:08:39

标签: ios google-maps google-maps-sdk-ios

我有一个简单的测试应用程序,其中我执行以下代码

    let marker = GMSMarker(position:CLLocationCoordinate2DMake(33.987884, -118.474434))
    marker.icon = GMSMarker.markerImageWithColor(UIColor.redColor())
    marker.panoramaView = panoramaView;
    marker.snippet = "I am Here!"

    panoramaView.moveNearCoordinate(marker.position)

如果我将坐标移动到海滩附近的其他街道,我可以看到标记就好了。但从上面的代码我什么都没看到。有没有人知道为什么我可以让一个区域在GMSPanoramaView中显示正常但是在那里放置一个标记不起作用?

1 个答案:

答案 0 :(得分:1)

我认为有些实施没有完成。不确定那些实现是什么,但我找到了一些关于你的问题的教程。或者根据文档"请注意,如果标记的位置离panoramaView的当前全景位置太远,它将不会显示,因为它太小"。

检查Street View locations and point-of-view (POV)

GMSPanoramaView *panoView_;
panoView_.camera = [GMSPanoramaCamera cameraWithHeading:180
                                              pitch:-10
                                               zoom:1];

街景视图中的标记

// Create a marker at the Eiffel Tower
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(48.858,2.294);
GMSMarker *marker = [GMSMarker markerWithPosition:position];

// Add the marker to a GMSPanoramaView object named panoView_
marker.panoramaView = panoView_;

// Add the marker to a GMSMapView object named mapView_
marker.map = mapView_;

这是第一个选项,Google Maps JavaScript API中的另一个选项是WebViewhttps://developers.google.com/maps/documentation/javascript/examples/streetview-overlays

var panorama;

function initMap() {
  var astorPlace = {lat: 40.729884, lng: -73.990988};

  // Set up the map
  var map = new google.maps.Map(document.getElementById('map'), {
    center: astorPlace,
    zoom: 18,
    streetViewControl: false
  });

  // Set up the markers on the map
  var cafeMarker = new google.maps.Marker({
      position: {lat: 40.730031, lng: -73.991428},
      map: map,
      icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=cafe|FFFF00',
      title: 'Cafe'
  });

  var bankMarker = new google.maps.Marker({
      position: {lat: 40.729681, lng: -73.991138},
      map: map,
      icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=dollar|FFFF00',
      title: 'Bank'
  });

  var busMarker = new google.maps.Marker({
      position: {lat: 40.729559, lng: -73.990741},
      map: map,
      icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=bus|FFFF00',
      title: 'Bus Stop'
  });

  // We get the map's default panorama and set up some defaults.
  // Note that we don't yet set it visible.
  panorama = map.getStreetView();
  panorama.setPosition(astorPlace);
  panorama.setPov(/** @type {google.maps.StreetViewPov} */({
    heading: 265,
    pitch: 0
  }));
}

function toggleStreetView() {
  var toggle = panorama.getVisible();
  if (toggle == false) {
    panorama.setVisible(true);
  } else {
    panorama.setVisible(false);
  }
}

以下是教程和repo代码的链接

相关问题