Google Maps API Multiple Custom Maps


	
var KumamotoTypeOptions = { getTileUrl: function(coord, zoom) { var normCoord = getNormalizedCoord(coord, zoom); if (!normCoord) { return null; } return "./tiles_demo" + "/" + "kumamoto" + "/" + "kumamoto_" + zoom + "_" + normCoord.x + "-" + normCoord.y + ".png"; }, tileSize: new google.maps.Size(256, 256), isPng: true, maxZoom: 5, minZoom: 2, name: 'Kumamoto' }; var KumamotoMapType = new google.maps.ImageMapType(KumamotoTypeOptions); var TaipeiTypeOptions = { getTileUrl: function(coord, zoom) { var normCoord = getNormalizedCoord(coord, zoom); if (!normCoord) { return null; } return "./tiles_demo" + "/" + "taipei" + "/" + "tile_" + zoom + "_" + normCoord.x + "-" + normCoord.y + ".png"; }, tileSize: new google.maps.Size(256, 256), isPng: true, maxZoom: 5, minZoom: 2, name: 'Taipei' }; var TaipeiMapType = new google.maps.ImageMapType(TaipeiTypeOptions); function initialize() { var mapKumamoto = ['Kumamoto'] var mapTaipei = ['Taipei'] var myLatlng = new google.maps.LatLng(0, 0); var myOptions = { center: myLatlng, zoom:2, mapTypeControl: true, streetViewControl: false, mapTypeControlOptions: { mapTypeIds: ['Kumamoto','Taipei'] } }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions ); map.mapTypes.set('Kumamoto',KumamotoMapType) map.mapTypes.set('Taipei',TaipeiMapType) map.setMapTypeId('Kumamoto'); map.setCenter(myLatlng); }
Created by