diff --git a/source/js/VMM.ExternalAPI.js b/source/js/VMM.ExternalAPI.js index e2f04e9..9128f11 100644 --- a/source/js/VMM.ExternalAPI.js +++ b/source/js/VMM.ExternalAPI.js @@ -233,55 +233,62 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') { } }, + defaultType: function(name) { + if (name.toLowerCase() == "satellite" || name.toLowerCase() == "hybrid" || name.toLowerCase() == "terrain" || name.toLowerCase() == "roadmap") { + return true; + } else { + return false; + } + }, + map_subdomains: ["", "a.", "b.", "c.", "d."], map_attribution: { - "stamen": "Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA.", - "apple": "Map data © 2012 Apple, Imagery © 2012 Apple" + "stamen": "Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA.", + "apple": "Map data © 2012 Apple, Imagery © 2012 Apple" }, map_providers: { "toner": { - "url": "http://{S}tile.stamen.com/toner/{Z}/{X}/{Y}.png", - "minZoom": 0, - "maxZoom": 20, - "attribution": "stamen" + "url": "http://{S}tile.stamen.com/toner/{Z}/{X}/{Y}.png", + "minZoom": 0, + "maxZoom": 20, + "attribution": "stamen" }, "toner-lines": { - "url": "http://{S}tile.stamen.com/toner-lines/{Z}/{X}/{Y}.png", - "minZoom": 0, - "maxZoom": 20, - "attribution": "stamen" + "url": "http://{S}tile.stamen.com/toner-lines/{Z}/{X}/{Y}.png", + "minZoom": 0, + "maxZoom": 20, + "attribution": "stamen" }, "toner-labels": { - "url": "http://{S}tile.stamen.com/toner-labels/{Z}/{X}/{Y}.png", - "minZoom": 0, - "maxZoom": 20, - "attribution": "stamen" + "url": "http://{S}tile.stamen.com/toner-labels/{Z}/{X}/{Y}.png", + "minZoom": 0, + "maxZoom": 20, + "attribution": "stamen" }, "sterrain": { - "url": "http://{S}tile.stamen.com/terrain/{Z}/{X}/{Y}.jpg", - "minZoom": 4, - "maxZoom": 20, - "attribution": "stamen" + "url": "http://{S}tile.stamen.com/terrain/{Z}/{X}/{Y}.jpg", + "minZoom": 4, + "maxZoom": 20, + "attribution": "stamen" }, "apple": { - "url": "http://gsp2.apple.com/tile?api=1&style=slideshow&layers=default&lang=en_US&z={z}&x={x}&y={y}&v=9", - "minZoom": 4, - "maxZoom": 20, - "attribution": "apple" + "url": "http://gsp2.apple.com/tile?api=1&style=slideshow&layers=default&lang=en_US&z={z}&x={x}&y={y}&v=9", + "minZoom": 4, + "maxZoom": 14, + "attribution": "apple" }, "watercolor": { - "url": "http://{S}tile.stamen.com/watercolor/{Z}/{X}/{Y}.jpg", - "minZoom": 3, - "maxZoom": 16, - "attribution": "stamen" + "url": "http://{S}tile.stamen.com/watercolor/{Z}/{X}/{Y}.jpg", + "minZoom": 3, + "maxZoom": 16, + "attribution": "stamen" } }, createMap: function(m) { - trace(VMM.ExternalAPI.googlemaps.stamen_map_attribution); /* MAP PROVIDERS Including Stamen Maps http://maps.stamen.com/ @@ -295,31 +302,40 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') { map_attribution = VMM.ExternalAPI.googlemaps.map_attribution[VMM.ExternalAPI.googlemaps.map_providers[name].attribution]; return VMM.ExternalAPI.googlemaps.map_providers[name]; } else { - throw 'No such provider: "' + name + '"'; + if (VMM.ExternalAPI.googlemaps.defaultType(name)) { + trace("GOOGLE MAP DEFAULT TYPE"); + return google.maps.MapTypeId[name.toUpperCase()]; + } else { + trace("Not a maptype: " + name ); + } } } google.maps.VeriteMapType = function(name) { - var provider = mapProvider(name); - return google.maps.ImageMapType.call(this, { - "getTileUrl": function(coord, zoom) { - var index = (zoom + coord.x + coord.y) % VMM.ExternalAPI.googlemaps.map_subdomains.length; - return [ - provider.url - .replace("{S}", VMM.ExternalAPI.googlemaps.map_subdomains[index]) - .replace("{Z}", zoom) - .replace("{X}", coord.x) - .replace("{Y}", coord.y) - .replace("{z}", zoom) - .replace("{x}", coord.x) - .replace("{y}", coord.y) - ]; - }, - "tileSize": new google.maps.Size(256, 256), - "name": name, - "minZoom": provider.minZoom, - "maxZoom": provider.maxZoom - }); + if (VMM.ExternalAPI.googlemaps.defaultType(name)) { + return google.maps.MapTypeId[name.toUpperCase()]; + } else { + var provider = mapProvider(name); + return google.maps.ImageMapType.call(this, { + "getTileUrl": function(coord, zoom) { + var index = (zoom + coord.x + coord.y) % VMM.ExternalAPI.googlemaps.map_subdomains.length; + return [ + provider.url + .replace("{S}", VMM.ExternalAPI.googlemaps.map_subdomains[index]) + .replace("{Z}", zoom) + .replace("{X}", coord.x) + .replace("{Y}", coord.y) + .replace("{z}", zoom) + .replace("{x}", coord.x) + .replace("{y}", coord.y) + ]; + }, + "tileSize": new google.maps.Size(256, 256), + "name": name, + "minZoom": provider.minZoom, + "maxZoom": provider.maxZoom + }); + } }; google.maps.VeriteMapType.prototype = new google.maps.ImageMapType("_"); @@ -328,96 +344,94 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') { ================================================== */ var layer; - if (type.of(VMM.master_config.Timeline.maptype) == "string") { - layer = VMM.master_config.Timeline.maptype; + if (VMM.ExternalAPI.googlemaps.defaultType(VMM.master_config.Timeline.maptype)) { + layer = google.maps.MapTypeId[VMM.master_config.Timeline.maptype.toUpperCase()]; + } else { + layer = VMM.master_config.Timeline.maptype; + } } else { - layer = "toner"; + layer = "toner"; } - var location = new google.maps.LatLng(41.875696,-87.624207); + var location = new google.maps.LatLng(41.875696,-87.624207); var latlong; - var zoom = 11; - var has_location = false; - var has_zoom = false; + var zoom = 11; + var has_location = false; + var has_zoom = false; var map_bounds; if (type.of(VMM.Util.getUrlVars(m.url)["ll"]) == "string") { - has_location = true; - latlong = VMM.Util.getUrlVars(m.url)["ll"].split(","); - location = new google.maps.LatLng(parseFloat(latlong[0]),parseFloat(latlong[1])); + has_location = true; + latlong = VMM.Util.getUrlVars(m.url)["ll"].split(","); + location = new google.maps.LatLng(parseFloat(latlong[0]),parseFloat(latlong[1])); } else if (type.of(VMM.Util.getUrlVars(m.url)["sll"]) == "string") { - latlong = VMM.Util.getUrlVars(m.url)["sll"].split(","); - location = new google.maps.LatLng(parseFloat(latlong[0]),parseFloat(latlong[1])); + latlong = VMM.Util.getUrlVars(m.url)["sll"].split(","); + location = new google.maps.LatLng(parseFloat(latlong[0]),parseFloat(latlong[1])); } if (type.of(VMM.Util.getUrlVars(m.url)["z"]) == "string") { - has_zoom = true; - zoom = parseFloat(VMM.Util.getUrlVars(m.url)["z"]); + has_zoom = true; + zoom = parseFloat(VMM.Util.getUrlVars(m.url)["z"]); } var map_options = { - zoom:zoom, - disableDefaultUI: true, - mapTypeControl: false, - zoomControl: true, + zoom: zoom, + disableDefaultUI: true, + mapTypeControl: false, + zoomControl: true, zoomControlOptions: { - style: google.maps.ZoomControlStyle.SMALL, - position: google.maps.ControlPosition.TOP_RIGHT + style: google.maps.ZoomControlStyle.SMALL, + position: google.maps.ControlPosition.TOP_RIGHT }, - center: location, - mapTypeId: layer, + center: location, + mapTypeId: layer, mapTypeControlOptions: { - mapTypeIds: [layer] + mapTypeIds: [layer] } } - var unique_map_id = m.id.toString() + "_gmap"; - VMM.attachElement("#" + m.id, "
"); + var unique_map_id = m.id.toString() + "_gmap"; - var map = new google.maps.Map(document.getElementById(unique_map_id), map_options); - map.mapTypes.set(layer, new google.maps.VeriteMapType(layer)); + VMM.attachElement("#" + m.id, ""); - /* ATTRIBUTION - ================================================== */ - var map_attribution_html = "