0
自從我嘗試一次又一次找到合適的地方,但沒有任何運氣。 我找不到在哪裏放置map.panby (x , y)
在我的下面的谷歌地圖代碼,以獲得更多的標記在右側的機器人。map.panby(x,y)在谷歌地圖代碼中放置的位置
如果有人可以幫助我,那將會很棒!
最佳
<script type="text/javascript">
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(52.5200066, 13.404954);
var mapOptions = {
zoom: 6,
scrollwheel: false,
navigationControl: false,
mapTypeControl: false,
scaleControl: false,
draggable: false,
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL,
position: google.maps.ControlPosition.LEFT_CENTER
},
streetViewControl:false,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
styles: [
{
"featureType": "administrative.country",
"elementType": "geometry",
"stylers": [
{ "weight": 1.2 },
{ "color": "#dd4b39" }
]
},{
"featureType": "administrative",
"stylers": [
{ "visibility": "simplified" }
]
},{
"featureType": "administrative.country",
"stylers": [
{ "visibility": "on" }
]
},{
"featureType": "administrative.locality",
"stylers": [
{ "visibility": "on" }
]
}
]
}
map = new google.maps.Map(document.getElementById('user-map-canvas'), mapOptions);
}
function showAddress(address) {
geocoder.geocode({ 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Adresse konnte aus folgendem Grund nicht gefunden werden: " + status);
}
google.maps.event.addListener(marker, 'click', function() { // Add a Click Listener to our marker
window.location='/freiwillige/?s=<?php echo $country ?>'; // URL to Link Marker to (i.e Google Places Listing)
});
});
}
jQuery(document).ready(function() { initialize(); showAddress('<?php echo $address ?>'); });
</script>
哇!這讓我更進一步!謝謝...... :) 但現在地圖集中在這裏定義的點:'var latlng = new google.maps.LatLng(52.5200066,13.404954);'而不是標記。 有沒有辦法解決這個問題呢? – Philipp
您是否希望地圖在初始化時或在地理編碼請求之後居中於標記? – Swires
嗯,我只是想達到它加載頁面時標記的中心,但標記應該稍微偏右。 ;) 非常感謝,這會讓我瘋狂! – Philipp