Qualcuno ha qualche consiglio su come mettere 2 mappe in una pagina utilizzando API Google Maps?
codice:
var map;
var birmingham = new google.maps.LatLng(coordinate, coordinate);
/**
* The HomeControl adds a control to the map that simply
* returns the user to London. This constructor takes
* the control DIV as an argument.
*/
function HomeControl(controlDiv, map) {
// Set CSS styles for the DIV containing the control
// Setting padding to 5 px will offset the control
// from the edge of the map
controlDiv.style.padding = '5px';
// Set CSS for the control border
var controlUI = document.createElement('DIV');
controlUI.style.backgroundColor = 'white';
controlUI.style.borderStyle = 'solid';
controlUI.style.borderWidth = '2px';
controlUI.style.cursor = 'pointer';
controlUI.style.textAlign = 'center';
controlUI.title = 'Click to set the map to Home';
controlDiv.appendChild(controlUI);
// Set CSS for the control interior
var controlText = document.createElement('DIV');
controlText.style.fontFamily = 'Arial,sans-serif';
controlText.style.fontSize = '12px';
controlText.style.paddingLeft = '4px';
controlText.style.paddingRight = '4px';
controlText.innerHTML = 'Title';
controlUI.appendChild(controlText);
// Setup the click event listeners: simply set the map to
// london
google.maps.event.addDomListener(controlUI, 'click', function() {
map.setCenter(london)
});
}
function initialize() {
var mapDiv = document.getElementById('map_canvas');
var myOptions = {
zoom: 15,
center: london,
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: true
}
map = new google.maps.Map(mapDiv, myOptions);
var infowindow = new google.maps.InfoWindow(
{ content: 'content',
position: london
});
infowindow.open(map);
var marker = new google.maps.Marker({
position: london,
map: map,
title:"title"
});
// Create the DIV to hold the control and
// call the HomeControl() constructor passing
// in this DIV.
var homeControlDiv = document.createElement('DIV');
var homeControl = new HomeControl(homeControlDiv, map);
homeControlDiv.index = 1;
map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);
}
Devo creare un altro script con coordinate diverse ed ovviamente anche nomi diversi di funzioni e variabili? Creando un'altra funzione che stampa la mappa posso, posso aggiungere 2 onload nel body?