On Aug 6, 5:36 am, svlad1983 <[email protected]> wrote: > I'm trying to use marcator projection with custom map and when I run > it I get the following JS error: > d[Ab] is not a function (main.js line 40). > > anybody can find the problem?
I can't run a debugger on the code you posted. Where is your map that exhibits the problem? http://groups.google.com/group/google-maps-js-api-v3/browse_frm/thread/2b3f101fd509919e?hl=en -- Larry > > var MERCATOR_RANGE = 256; > > function bound(value, opt_min, opt_max) { > if (opt_min != null) value = Math.max(value, opt_min); > if (opt_max != null) value = Math.min(value, opt_max); > return value; > } > function degreesToRadians(deg) { > return deg * (Math.PI / 180);} > > function radiansToDegrees(rad) { > return rad / (Math.PI / 180); > > } > > function MercatorProjection() { > this.pixelOrigin_ = new google.maps.Point(MERCATOR_RANGE / 2, > MERCATOR_RANGE / 2); > this.pixelsPerLonDegree_ = MERCATOR_RANGE / 360; > this.pixelsPerLonRadian_ = MERCATOR_RANGE / (2 * Math.PI); > > }; > > MercatorProjection.prototype.fromLatLngToPoint = function(latLng, > opt_point) { > var me = this; > > var point = opt_point || new google.maps.Point(0, 0); > > var origin = me.pixelOrigin_; > point.x = Math.round(origin.x + latLng.lng() * > me.pixelsPerLonDegree_); > // NOTE(appleton): Truncating to 0.9999 effectively limits > latitude to > // 89.189. This is about a third of a tile past the edge of the > world tile. > var siny = bound(Math.sin(degreesToRadians(latLng.lat())), > -0.9999, 0.9999); > > point.y = Math.round(origin.y + 0.5 * Math.log((1 + siny) / (1 - > siny)) * -me.pixelsPerLonRadian_); > return point; > > }; > > MercatorProjection.prototype.fromPointToLatLng = function(point) { > var me = this; > > var origin = me.pixelOrigin_; > var lng = (point.x - origin.x) / me.pixelsPerLonDegree_; > var latRadians = (point.y - origin.y) / -me.pixelsPerLonRadian_; > var lat = radiansToDegrees(2 * Math.atan(Math.exp(latRadians)) - > Math.PI / 2); > return new google.maps.LatLng(lat, lng); > > }; > > function initialize() { > var latlng = new google.maps.LatLng(44,3); > var MyMapType = new google.maps.ImageMapType({ > getTitleUrl: function(coord, zoom) { > return "http://vec.maps.yandex.net/tiles?l=map&v=2.14.0&x=" > + coord.x +"&y=" + coord.y +"&z=" + zoom; > }, > tileSize: new google.maps.Size(256,256), > isPng: true, > minZoom: 0, > maxZoom: 17, > name: 'MyMap' > }); > MyMapType.projection = new MercatorProjection(); > > var myOptions ={ > zoom: 8, > center: latlng, > mapTypeId: google.maps.MapTypeId.ROADMAP > }; > map = new > google.maps.Map(document.getElementById("map_canvas"), myOptions); > map.mapTypes.set('myMap', MyMapType); > map.setMapTypeId('myMap'); > > } -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
