Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getNormalizedCoord(coord, zoom) {
- var y = coord.y;
- var x = coord.x;
- // tile range in one direction range is dependent on zoom level
- // 0 = 1 tile, 1 = 2 tiles, 2 = 4 tiles, 3 = 8 tiles, etc
- var tileRange = 1 << zoom;
- // don't repeat across y-axis (vertically)
- if (y < 0 || y >= tileRange) {
- return null;
- }
- // repeat across x-axis
- if (x < 0 || x >= tileRange) {
- x = (x % tileRange + tileRange) % tileRange;
- }
- return {
- x: x,
- y: y
- };
- }
- var map;
- function initMaps() {
- $.getScript("http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/src/infobox.js").done(function (script, textStatus) {
- var customMapTypeOptions = {
- getTileUrl: function (coord, zoom) {
- var normalizedCoord = getNormalizedCoord(coord, zoom);
- if (!normalizedCoord) {
- return null;
- }
- var bound = Math.pow(2, zoom);
- console.log('http://img.photobucket.com/albums/v229/s15199d/ + normalizedCoord.x + '-' + (bound - normalizedCoord.y - 1) + '.png');
- return 'http://img.photobucket.com/albums/v229/s15199d/ + normalizedCoord.x + '-' + (bound - normalizedCoord.y - 1) + '.png';
- },
- tileSize: new google.maps.Size(250, 250),
- maxZoom: 0,
- minZoom: 0,
- radius: 1738000,
- name: 'custom map'
- };
- var customMapType = new google.maps.ImageMapType(customMapTypeOptions);
- var latlng = new google.maps.LatLng(0, 0), // center point
- mapOptions = {
- zoom: 0,
- center: latlng,
- draggable: true,
- scrollwheel: false,
- mapTypeControl: false,
- panControl: false,
- scaleControl: false,
- zoomControl: true,
- zoomControlOptions: {
- style: google.maps.ZoomControlStyle.LARGE,
- position: google.maps.ControlPosition.RIGHT_TOP
- },
- streetViewControl: false,
- streetViewControlOptions: {
- position: google.maps.ControlPosition.RIGHT_TOP
- },
- mapTypeControlOptions: {
- mapTypeIds: ['custom map']
- }
- };
- map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
- map.mapTypes.set('custom map', customMapType);
- map.setMapTypeId('custom map');
- });
- }
- $(function () {
- if (window.google && google.maps) {
- //alert("Map script is already loaded. Initializing");
- initMaps();
- } else {
- //alert("Lazy loading Google map...");
- lazyLoadGoogleMap();
- }
- });
- function lazyLoadGoogleMap() {
- $.getScript("http://maps.google.com/maps/api/js?sensor=true&callback=initMaps")
- .done(function (script, textStatus) {
- //alert("Google map script loaded successfully");
- })
- .fail(function (jqxhr, settings, ex) {
- //alert("Could not load Google Map script: " + jqxhr);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement