I use a static map (image) from google in a mobile phone app. What i have is: the longitude-latitude data from the center (of the image), the size of image, the zoomlevel.
How can i calculate the longitude-latitude data of the top-left (or any other place) of the image?
You need to compute the lat/lon from a range/bearing calculation (see destination point from distance and bearing given here: http://www.movable-type.co.uk/scripts/latlong.html). The zoom level will give you the range part. For the bearing part, is the map north up? If it is, then the bearing for the upper left will be 315 degrees (360 - 45). If you don't know if the map is north up, then you will need another lat/lon point.
Related
I have an image which 21810x14872 that project a box of an area with coordinate:
top, left corner latitude longitude : 23.635069763547662 , 58.09107365049769 bottom, right corner latitude longitude : 23.598520470202025 , 58.14957297881731
OR using WGS84 northing, easting:
top, left corner easting, northing : 617289.588, 2610249.342 bottom, right corner easting, northing : 611289.588, 2614249.428
My image use projection of WGS84. I'm not sure which Coordinate System in Maptiler I need to select? Please advice.
Thanking You.
The answer is equal to: Creating world file for maptiler
In MapTiler (http://www.maptiler.com/) you can use the "Bounding Box" georeferencing - to provide the four limiting coordinates (north, south, east, west) you mentioned above to assign location to your image directly. You probably don't need to create a World file then.
Just choose in MapTiler the "Mercator tiles", then drag&drop in your file, select your coordinate system (default is the WGS84 geodetic latitude / longitude) and on assign location click on Bounding box. A dialog opens when you can directly type the four numbers. MapTiler previews the covered area in the small map window in bottom right corner.
See these video tutorials which demonstrate the usage of Bounding Box:
https://www.youtube.com/watch?v=p8rNkaNXDPs&list=PLGHe6Moaz52PiQd1mO-S9QrCjqSn1v-ay
and another which also generates MBTiles and upload these to Amazon S3:
https://www.youtube.com/watch?v=pf8itiTwo6w&list=PLGHe6Moaz52PiQd1mO-S9QrCjqSn1v-ay
BTW WGS84 is a world geodetic system (latitude and longitude) in degrees. It is not a map projection nor projected system. The second coordinates you mentioned look like UTM coordinates or another projected coordinates in meters. To use these you would need to know the exact coordinate system definition (ideally so called EPSG code - see our http://epsg.io/).
I have an image which 21810x14872 that project a box of an area with coordinate:
top, left corner latitude longitude : 23.635069763547662 , 58.09107365049769
bottom, right corner latitude longitude : 23.598520470202025 , 58.14957297881731
OR using WGS84 northing, easting:
top, left corner easting, northing : 617289.588, 2610249.342
bottom, right corner easting, northing : 611289.588, 2614249.428
My image use projection of WGS84. How do I create world file for maptiler using above description.
Thanking You.
In MapTiler (http://www.maptiler.com/) you can use the "Bounding Box" georeferencing - to provide the four limiting coordinates (north, south, east, west) you mentioned above to assign location to your image directly. You probably don't need to create a World file then.
Just choose in MapTiler the "Mercator tiles", then drag&drop in your file, select your coordinate system (default is the WGS84 geodetic latitude / longitude) and on assign location click on Bounding box. A dialog opens when you can directly type the four numbers. MapTiler previews the covered area in the small map window in bottom right corner.
See these video tutorials which demonstrate the usage of Bounding Box:
https://www.youtube.com/watch?v=p8rNkaNXDPs&list=PLGHe6Moaz52PiQd1mO-S9QrCjqSn1v-ay
and another which also generates MBTiles and upload these to Amazon S3:
https://www.youtube.com/watch?v=pf8itiTwo6w&list=PLGHe6Moaz52PiQd1mO-S9QrCjqSn1v-ay
BTW WGS84 is a world geodetic system (latitude and longitude) in degrees. It is not a map projection nor projected system. The second coordinates you mentioned look like UTM coordinates or another projected coordinates in meters. To use these you would need to know the exact coordinate system definition (ideally so called EPSG code - see our http://epsg.io/).
I am writing some code which clusters markers on a Google map. The clustering algorithm relies on knowing how many degrees latitude and longitude are currently visible to the user, as I break the map into a grid of n/map_pixels_width x n/map_pixels_height squares and need to know how many degrees of lat/lon are in each square to know which square each marker point belongs to.
Under normal circumstances where the map does not wrap this is relatively easy to calculate using getBounds() on the Google Map object and doing the calculations to figure out the latitudinal and longitudinal distances between the returned North-East and Sout-West points. Where I'm running into issues is where the map is zoomed out to the extent that it wraps the entire Earth > 1 times. For example, I can zoom out the map so that the entire Earth is "tiled" 5 times over which equates to 360 * 5 = 1800 longitudinal degrees and, but then the call to getBounds() no longer provides useful information:
m.getBounds().getNorthEast().lat()
88.31833020528785
m.getBounds().getNorthEast().lng()
180
m.getBounds().getSouthWest().lat()
-88.5485785544835
m.getBounds().getSouthWest().lng()
-180
Basically, the longitudes getBounds() reports are just the min and max for one whole globe which says nothing about how many times the Earth is repeated. Although Google Maps doesn't tile the map vertically (it just inserts gray filing space if zoomed out far enough), I have conceptually the same problem -- I need to know how many total degrees of space the vertical area would consume.
Is there a way to get the total number of visible longitudinal degrees?
So based on this answer to another question, I found a (hackish) way to solve this. Basically, the Google Maps OverlayView class has a getProjection() method returning a MapCanvasProjection object, which in turn has a getWorldWidth() method which returns the width of the world at the current zoom level in pixels. So the way to solve the problem then is to:
Add a dummy OverlayView to the map that doesn't actually present an overlay.
Get the overlay's projection.
Get the world width from the projection.
Calculate the number of visible longitudinal degrees as pixel_width_of_map_element / world_width_in_pixels * 360
It would be better if there were a way to do this without creating a dummy overlay, but this method seems to work.
There is a way to convert a distance (in kilometers) into a float zoom level of a GMSCameraPosition?
I have an app where the user specifies a diameter (in kilometers) that he wants to see around the gps checkmark (his position). So, I need to convert that distance (like, 30 km) into a zoom level that fits that distance in kilometers.
I'm very new with Google Maps and didn't find a way to that until now.
Thanks in advance.
For calculating with GPS coordinates have a look here. (Especially the section "Destination point given distance and bearing from start point").
When you have your coordinates you can use the fitBounds-method of the Map-object which does exactly what you want.
I have a Map object created through the google maps api and I want to figure out the distance (km or mi) between the corners of the current view. I know how to get the coordinates of the corners, is there a utility function to calculate the distance between points?
From: http://code.google.com/apis/maps/documentation/reference.html#GLatLng
GLatLng.distanceFrom( other:GLatLng,
radius?:Number );
Returns the distance, in meters, from
this location to the given location.
By default, this distance is
calculated given the default
equatorial earth radius of 6378137
meters. The earth is approximated as a
sphere, hence the distance could be
off as much as 0.3%, especially in the
polar extremes. You may also pass an
optional radius argument to calculate
distances between GLatLng coordinates
on spheres of a different radius than
earth.
This somewhat depends on how accurate you need your answer to be.
The Google Maps API includes a function called distanceFrom, which will probably work just fine for you:
Returns the distance, in meters, from
this location to the given location.
By default, this distance is
calculated given the default
equatorial earth radius of 6378137
meters. The earth is approximated as a
sphere, hence the distance could be
off as much as 0.3%, especially in the
polar extremes. You may also pass an
optional radius argument to calculate
distances between GLatLng coordinates
on spheres of a different radius than
earth.
If you need a more accurate answer, you will need a function that takes the shape of the Earth into consideration. I haven't tried it, but this one looks great.