I have written a tile image generator for use with overlay.getTileUrl(tileCoord,zoom) that works as expected for map type Road_Map for zoom levels to 21
function tile2lng(x,z) { return (x/Math.pow(2,z)*360-180); }
function tile2lat(y,z) { var n=Math.PI-2*Math.PI*y/Math.pow(2,z);
return (180/Math.PI*Math.atan(0.5*(Math.exp(n)-Math.exp(-n)))); }
at lat/lng 37.21 / -77.26
When the Satellite map is zoomed to level 18 the tile coordinates for the requested overlay tile calculate to lat/lng 27.37 / -77.26
Actually, there seem to be two passes at loading the map. First tile lat/lng is requested correctly, then a Projection_Changed event occurs, and then tiles are re-requested with lat/lng calculated incorrectly. It seems the projection for Satellite tiles displayed at map zoom 18 to 21 is not the standard Google mercator projection. How should this change be detected by overlay.getTileURL(coord,zoom) ?
What is the proper way to calculate lat/lng for Satellite tiles when map zoomed 18 to 21 ?
And the answer is: at this time, there are no exposed projection parameters.
What I really needed:
map.setTilt(0);
I did not realize Google Maps automatically rendered satelite zoom 18 and higher with tilt set at 45 which changes the standard base map projection.
Happy days!
Related
I'm trying to stitch together tiles onto a Windows directX 9 screen. My problem is that the tiles are stair-stepped on the screen. I think this is because on my Cartesian coordinate system has the same Y given the same latitude independent of X (or longitude).
My app uses the Proj4 APIs to convert to/from lat/lng and a user-chosen coordinate system (e.g., NAD83, Zone Connecticut) which is Model X/Y cartesian. I'm using the slippy C# code (https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#C.23) to convert to/from lat/lng and tiles. So, I convert as follows View-> Model X/Y -> lat/lng -> Tile X/Y -> lat/lng -> Model X/Y -> View.
Any suggestions on how to get this to work? Changing my coordinate system for my view rendering is not an option because customers import DXF files that are using those Cartesian coordinate systems.
I made the incorrect assumption that my screen projection was perfect lat/lng tiles. A straight horizontal line on a state-mapped projection does not maintain the same latitude whereas the tiles do. When rendering my texture, I just had to make sure all corners were converted to my Model coordinates, thus stretching the image to the upper right and lower left slightly.
I have a simple Google Map. I've added a marker at a given lat, lng.
I want to use turf.js to calculate a 1km buffer which I can then display as a Google Maps polygon.
The path that turf.buffer() returns is an ellipse. The distance from the marker to the boundary is correct latitudinally. However it is short of 1km longitudinally. It looks like there is a problem with the projection, however both the Google Maps API and turf.js documents state WGS84 is the default projection.
The end game is using turf.js to buffer Points, Polylines and Polygons so I can't just draw a Google Maps circle as a workaround unfortunately. I would consider migrating to Leaflet, however we are already quite invested in developing for the Google Maps API
I've created an htm file here showing the problem
I'm not going nuts. The buffer isnt geodesic so at the equator you get a round buffer and as you move north or south your buffer becomes squashed longitudinally towards the poles. The turf.js team are aware. See https://github.com/Turfjs/turf/issues/110 for full details.
I'm looking at using clipper.js instead. This is a cartesian library (2d) so in the uk i can use osgb eastings and northings. I will also have to flip north and south as clipper assumes we are dealing with standard graphics i.e. The y axis is inverted like in css with 0,0 being the top left.
Im going to use geotools to transform between osgb and wgs.
I have a map, which is accurate (enough) to the real world map, as viewed in google maps.
I'm projecting the drawn image using the google.maps.ImageMapType class, thus the corners of the new, drawn, map are (sw)-90,-180 and (ne)90,180.
Now, knowing the coordinates of the south-west and north-east of the overlay in the real-world map, how do I convert GPS coordinates to this new scale?
OK, I added a marker in "Paris" to your jsFiddle, but the marker is clearly not where it should be.
I think you might be mixing google.maps.MapType object and google.maps.ImageMapType
google.maps.ImageMapType uses a google.maps.ImageMapTypeOptions object, which should have a getTileUrl() method, but instead you have a getTile() method which is breaking the projection.
I need the terrain view but cant seem to show it at 45 degrees. I dont want to use the google earth plug-in though. Can this be done? If not: are there other map apis that do this?
It can't be done with Google Maps API. Tilted maps are only available with the satellite/aerial tiles.
The docs state "setTilt(): Sets the angle of incidence for aerial imagery (available for SATELLITE and HYBRID map types) measured in degrees from the viewport plane to the map plane. The only supported values are 0, indicating no angle of incidence (no tilt), and 45 indicating a tilt of 45deg."
i have got center of map using map.getCenter(); and i got current zoom of google map using getZoom(); please tell me how can i calculate/get current show mils area in google map. i am using asp.net and javascript.
With GMap2.getBounds() you can get the visible rectangular region of the map view.
Then using these coordinates you can construct a GPolygon object and calculate the area in square meters using GPolygon.getArea() function. Then convert given area to mils (1 meter = 39 370.0787 mils).
the GLatLng object has a distanceFrom function that takes another GLatLng. The map has getBounds from which you'll be able to get the corners of interest, and check the distance between them.