我有一个简单的测试应用程序,我在其中执行以下代码
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 中正常显示,但是在那里放置一个标记不起作用?
我认为有些实现没有完成。不确定这些实现是什么,但我找到了一些关于您的问题的教程。或者根据文档“注意,如果marker的位置离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_;
这是第一个选项,另一个选项是 WebView
内的 Google Maps JavaScript API
。 https://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
链接
关于ios - 标记未显示在 GMSPanoramaView 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37304881/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (https://ogeek.cn/) | Powered by Discuz! X3.4 |