Google maps uses mercator projection. On Tue, Sep 7, 2010 at 2:29 PM, chaoskreator <[email protected]> wrote:
> I'm actually using the euclidean projection and didn't realize it. > lol. > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http:// > www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas- > microsoft-com:vml"> > <head> > <meta http-equiv="content-type" content="text/html/xml; > charset=utf-8"/> > <meta name="author" content="Richard Milton, Centre for Advanced > Spatial Analysis (CASA), University College London (UCL)"> > <meta name="description" content="Page automatically created by > GMapImageCutter created by CASA"> > <meta name="keywords" content="Google, Maps, Image, Images, Tile, > Cutter, GMapImageCutter, GMapCreator"> > > <title>Picture Viewer</title> > > <style type="text/css"> > v\:* { > behavior:url(#default#VML); > } > </style> > > <script src="http://maps.google.com/maps? > > file=api&v=2.x&key=ABQIAAAALMGB89c6c_J7pKZfWpDH3xQVJ344EdPYk9JfYNQ577kXhmBX5BR08n6HeITeJ1sTonZYs91fpHXt1A" > type="text/javascript"></script> > <script type="text/javascript"> > //<![CDATA[ > > var centreLat=0.0; > var centreLon=0.0; > var initialZoom=1; > var imageWraps=false; //SET THIS TO false TO PREVENT THE > IMAGE > WRAPPING AROUND > var map; //the GMap2 itself > var htmls = 0; > var gicons = []; > var leader = new GIcon(G_DEFAULT_ICON, "colour086.png"); > var vice = new GIcon(G_DEFAULT_ICON, "colour108.png"); > var officer = new GIcon(G_DEFAULT_ICON, "colour125.png"); > var pin = new GIcon(G_DEFAULT_ICON, "marker.png"); > > function createMarker(point, icon, popuphtml) > { > var popuphtml = "<div id=\"popup\">" + popuphtml + > "<\/div>"; > var marker = new GMarker(point, icon); > GEvent.addListener(marker, "click", function() > { > marker.openInfoWindowHtml(popuphtml); > }); > return marker; > } > > function CustomProjection(a,b) > { > this.imageDimension=65536; > this.pixelsPerLonDegree=[]; > this.pixelOrigin=[]; > this.tileBounds=[]; > this.tileSize=256; > this.isWrapped=b; > var b=this.tileSize; > var c=1; > for(var d=0;d<a;d++) > { > var e=b/2; > this.pixelsPerLonDegree.push(b/360); > this.pixelOrigin.push(new GPoint(e,e)); > this.tileBounds.push(c); > b*=2; > c*=2 > } > } > > CustomProjection.prototype=new GProjection(); > > > CustomProjection.prototype.fromLatLngToPixel=function(latlng,zoom) > { > var c=Math.round(this.pixelOrigin[zoom].x > +latlng.lng()*this.pixelsPerLonDegree[zoom]); > var d=Math.round(this.pixelOrigin[zoom].y+ > (-2*latlng.lat())*this.pixelsPerLonDegree[zoom]); > return new GPoint(c,d) > }; > > > CustomProjection.prototype.fromPixelToLatLng=function(pixel,zoom,unbounded) > { > var d=(pixel.x-this.pixelOrigin[zoom].x)/ > this.pixelsPerLonDegree[zoom]; > var e=-0.5*(pixel.y-this.pixelOrigin[zoom].y)/ > this.pixelsPerLonDegree[zoom]; > return new GLatLng(e,d,unbounded) > }; > > > CustomProjection.prototype.tileCheckRange=function(tile,zoom,tilesize) > { > var tileBounds=this.tileBounds[zoom]; > if (tile.y<0 || tile.y >= tileBounds) {return > false;} > if (this.isWrapped) > { > if (tile.x<0 || tile.x>=tileBounds) > { > tile.x = tile.x%tileBounds; > if (tile.x < 0) {tile.x+=tileBounds} > } > } > else > { > if (tile.x<0 || tile.x>=tileBounds) {return > false;} > } > return true; > } > > CustomProjection.prototype.getWrapWidth=function(zoom) > { > return this.tileBounds[zoom]*this.tileSize; > } > > function customGetTileURL(a,b) > { > //converts tile x,y into keyhole string > > var c=Math.pow(2,b); > > var d=a.x; > var e=a.y; > var f="t"; > for(var g=0;g<b;g++) > { > c=c/2; > if(e<c) > { > if(d<c){f+="q"} > else{f+="r";d-=c} > } > else > { > if(d<c){f+="t";e-=c} > else{f+="s";d-=c;e-=c} > } > } > return "koc-tiles/"+f+".jpg" > } > > function load() > { > if (GBrowserIsCompatible()) > { > var copyright = new GCopyright(1, new > GLatLngBounds(new GLatLng(0, > 0), new GLatLng(749, 749)), 0, "Lord chaoskreator, bitches."); > var copyrightCollection = new > GCopyrightCollection("(c)"); > copyrightCollection.addCopyright(copyright); > > //create a custom picture layer > var pic_tileLayers = [ new > GTileLayer(copyrightCollection , 0, > 17)]; > pic_tileLayers[0].getTileUrl = > customGetTileURL; > pic_tileLayers[0].isPng = function() { > return false; }; > pic_tileLayers[0].getOpacity = function() { > return 1.0; }; > var pic_customMap = new > GMapType(pic_tileLayers, new > CustomProjection(6,imageWraps), "Pic", {maxResolution:4, minResolution: > 0, errorMessage:"Data not available"}); > > // This function picks up the click and > opens the corresponding > info window > function myclick(i) > { > > gmarkers[i].openInfoWindowHtml(htmls[i]); > } > > //Now create the custom map. Would normally > be > G_NORMAL_MAP,G_SATELLITE_MAP,G_HYBRID_MAP > map = new > GMap2(document.getElementById("map"),{mapTypes: > [pic_customMap]}); > map.addControl(new GLargeMapControl()); > map.addControl(new GMapTypeControl()); > map.addControl(new GOverviewMapControl()); > map.enableDoubleClickZoom(); > map.enableScrollWheelZoom(); > map.setCenter(new GLatLng(centreLat, > centreLon), initialZoom, > pic_customMap); > > > ///////////////////////////////////////////////////////////////////////////////////// > //Add any markers here e.g. > map.addOverlay(new createMarker(new > GLatLng(374,533), officer, > "Chaos<br />374,533<br />Officer")); > > ///////////////////////////////////////////////////////////////////////////////////// > > } > } > > //]]> > </script> > </head> > <body onload="load()" onunload="GUnload()"> > <div id="map" style="height:768px;width:768px;margin:0 auto;text- > align:center;"></div> > </body> > </html> > > > > Do I need to convert from latlng to pixel? > > On Sep 7, 4:28 am, Martin <[email protected]> wrote: > > Yes you need to change the map type from Mercator to Euclidean and > > back to see the effect of the different projections. > > > > Martin. > > > > On 7 Sep, 07:23, chaoskreator <[email protected]> wrote: > > > > > My apologies. It is now open again. > > > > > I've reviewed that page, but both the examples point to the same map > > > page. > > > > > On Sep 7, 12:23 am, Martin <[email protected]> wrote: > > > > > > Hi. > > > > > > Your map page (linked to above) is now password protected so no-one > > > > can look at your latest code. > > > > > > But i'd suggest you look at a pixel coordinate type custom > projection:http://econym.org.uk/gmap/customflat.htm > > > > > > Martin. > > > > > > On 7 Sep, 04:18, chaoskreator <[email protected]> wrote: > > > > > > > Okay, I seem to have worked through several issues and have plotted > a > > > > > custom marker. The only problem is that the marker is way off from > > > > > where it is supposed to be. And it stays in the same position on > the > > > > > screen when the map is moved around. It has to be something with > the > > > > > map boundaries, but I'm not sure what. > > -- > You received this message because you are subscribed to the Google Groups > "Google Maps API" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-maps-api%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-maps-api?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Maps API" 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-api?hl=en.
