저는 아직 자바 스크립트를 많이 익히지 않았으며 이것은 제 1 번째 게시물입니다.Google지도 v3 특정 위치 확대/축소
function initialize() {
// Create the map
// No need to specify zoom and center as we fit the map further down.
var map = new google.maps.Map(document.getElementById("map_canvas"), {
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: false,
});
// Create the shared infowindow with two DIV placeholders
// One for a text string, the other for the StreetView panorama.
var content = document.createElement("DIV");
var title = document.createElement("DIV");
content.appendChild(title);
var streetview = document.createElement("DIV");
streetview.style.width = "200px";
streetview.style.height = "200px";
content.appendChild(streetview);
var infowindow = new google.maps.InfoWindow({
content: content
});
var markers = [{
lat: 35.15074,
lng: -89.955992,
name: "Bob 1"
}, {
lat: 35.149425,
lng: -89.946595,
name: "Bob 2"
}, {
lat: 35.146687,
lng: -89.929837,
name: "Bob 3"
}, {
lat: 35.132264,
lng: -89.937197,
name: "Bob 4"
}];
// Create the markers
for (index in markers) addMarker(markers[index]);
function addMarker(data) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(data.lat, data.lng),
map: map,
title: data.name
});
google.maps.event.addListener(marker, "click", function() {
openInfoWindow(marker);
});
}
// Zoom and center the map to fit the markers
// This logic could be conbined with the marker creation.
// Just keeping it separate for code clarity.
var bounds = new google.maps.LatLngBounds();
for (index in markers) {
var data = markers[index];
bounds.extend(new google.maps.LatLng(data.lat, data.lng));
}
map.fitBounds(bounds);
// Handle the DOM ready event to create the StreetView panorama
// as it can only be created once the DIV inside the infowindow is loaded in the DOM.
var panorama = null;
var pin = new google.maps.MVCObject();
google.maps.event.addListenerOnce(infowindow, "domready", function() {
panorama = new google.maps.StreetViewPanorama(streetview, {
navigationControl: false,
enableCloseButton: false,
addressControl: false,
linksControl: false,
visible: true
});
panorama.bindTo("position", pin);
});
// Set the infowindow content and display it on marker click.
// Use a 'pin' MVCObject as the order of the domready and marker click events is not garanteed.
function openInfoWindow(marker) {
title.innerHTML = marker.getTitle();
pin.set("position", marker.getPosition());
infowindow.open(map, marker);
}
}
자바 스크립트 내가 4 개 개의 다른 장소를했다, 그럼 내가 4 개 웹 페이지가 나는 특정 위치를 확대하려는 브라우저를 말하는 방법, 추가해야합니다. "Bob 1"을 확대하고 싶다고합시다. 그런 다음 웹 페이지의 이름을 bob1.html로 변경합니다. 내가 bob1.html을 클릭 할 때마다 웹 페이지는 zoom: 15
확대되고 마커는지도의 중심에 위치합니다.
레스토랑을 클릭하면 위치가 표시됩니다. 스크립트를 가져 주셔서 감사합니다,하지만 만약 내가 내 PHP에 넣어 지원 해요 – charmine
당신이 언급 한 시나리오를 고려하여 편집을 참조하십시오. – Swires
URL 매개 변수에 대한 더 많은 연구가 필요합니다. >. < 만약 내가 어떤 솔루션을 내 PHP 파일에서 콜백 수 내 특정 'var 표식'확대/축소 – charmine