gpt4 book ai didi

google-maps - 在标记内集成谷歌街景

转载 作者:行者123 更新时间:2023-12-01 12:00:49 25 4
gpt4 key购买 nike

当我们在 Google map 网站上搜索地址时,如果该地址的街景 View 可用,其标记会添加一个带有链接的小图像,以查看该区域的街景 View 。

我的问题是,我可以将这样的东西与我的自定义 map 集成吗?

一个例子是:

http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=30+Daniel+Webster+Hwy,+East+Merrimack,+NH+03054&sll=35.101934,-95.712891&sspn=48.649293,93.076172&ie=UTF8&hq=&hnear=30+Daniel+Webster+Hwy,+East+Merrimack,+Hillsborough,+New+Hampshire+03054&z=16

检查标记 - 我想要这样的东西;

问候,

PS:我知道一定有办法,但我的时间很紧;尽快需要一个解决方案 - 用谷歌搜索,但还没有找到出路。

最佳答案

嗯;终于我能够做到了 - 虽然不是完全 100% 复制谷歌地图。

以下是代码 - 只是发布以供其他人将来引用:

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=KEY" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var map;
var geocoder;

function load()
{
if (GBrowserIsCompatible())
{
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(40, -80), 1);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setZoom(14);

geocoder = new GClientGeocoder();
geocoder.getLocations( "<%=me.Address %>", addAddressToMap );
}
}

function addAddressToMap( response )
{
if (!response || response.Status.code != 200)
{
alert("Sorry, we were unable to geocode that address");
return;
}

place = response.Placemark[0];
point = new GLatLng( place.Point.coordinates[1], place.Point.coordinates[0] );

var lat = place.Point.coordinates[1];
var lng = place.Point.coordinates[0];

var letter = String.fromCharCode( "A".charCodeAt( 0 ) );

var baseIcon = new GIcon();
baseIcon.iconSize = new GSize( 32, 32 );
baseIcon.shadowSize = new GSize( 37, 34 );
baseIcon.iconAnchor = new GPoint( 9, 34 );
baseIcon.infoWindowAnchor = new GPoint( 9, 2 );
baseIcon.infoShadowAnchor = new GPoint( 18, 25 );

marker = new GMarker( point );

map.addOverlay( marker );
map.panTo( point );
marker.openInfoWindowHtml( "<strong><%=me.Name %></strong><br /><%=me.AddressForDisplay %>" );

var point = new GLatLng( lat, lng );
panoramaOptions = { latlng:point };
pano = new GStreetviewPanorama( document.getElementById( "streetview" ), panoramaOptions );

GEvent.addListener( pano );
GEvent.addListener( pano, "error", handleNoFlash );
}
function handleNoFlash( code )
{
if ( code == GStreetviewPanorama.ErrorValues.FLASH_UNAVAILABLE )
alert( 'You need flash player to view the panorama.' );

document.getElementById( "toggle" ).style.display = 'none';
}
function Toggle()
{
if( document.getElementById( "streetview" ).style.display == 'none' )
{
document.getElementById( "streetview" ).style.display = 'block';
document.getElementById( "map" ).style.display = 'none'
document.getElementById( "toggle" ).innerHTML = "<a href='javascript:Toggle();'>Map View</a>";
}
else
{
document.getElementById( "map" ).style.display = 'block';
document.getElementById( "streetview" ).style.display = 'none'
document.getElementById( "toggle" ).innerHTML = "<a href='javascript:Toggle();'>Street View</a>";
}
}
//]]>
</script>

对于正文:

<body onload="load()" onunload="GUnload()">
<div id="toggle"><a href='javascript:Toggle();'>Street View</a></div>
<div id="map" style="width:650px; height: 400px;"></div>
<div id="streetview" style="width:650px; height: 400px; display:none;"></div>

关于google-maps - 在标记内集成谷歌街景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1742457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com