When setting a custom image for the map markers (Annotations) on a Skobbler map, one can set the offset of the image using SKAnnotation.seOffset(SKScreenPoint), so that the marker can line up proprly with the exact location of gps coordinates, but the documentation is not clear on what the unit of measurement is for SKScreenPoint or how the offset is calculated.
Is the offset in dip, px, or something else.
Is there a built in way to handle different screen densities using, or do I need to calculate the value based on screen density?
Offset in px.
For example, to set anchor point from center to bottom of annotation offset should be half of height:
annotation.setOffset(new SKScreenPoint(0 /*x*/, annotation_height/2 /*y*/));
Related
I am try to implement a hand-painted app by android (like infinite design )
and decide to use vector because it can scale and not distortion.
I think a lot and try to use the mode of viewport-horizon-world
Viewport which rely on the sizeof phone (etc 1080*1920) it is the path you see and you touch
Horizon the thing which will display on viewport
World the real coordinates of the point(which make up the path etc line
,bessel).
this model works like
first you touch the screen of phone and horizon will translate the point to the real world coordinates (if you move of scale) and save the value to world
second you can move and scale by gestures it will change the attribute of horizon etc you move left 100 and down 100 the horizon will know now it offset (100,100) and the bound will change ((0,0),(1080,1920))->((100,100),(1180,2020))
last when draw i find the path which include in horizon (calculate the bound of horizon and the bound of path) then calculate the display coordinate rely on horizonand draw the path by canvas.draw() etc
now the problem is when i just offset the horizon ,calculate the display coordinate just need to plus the offset values.but when scale it become difficult.for example a path bound in ((0,0),(100,100)) and the horizon scale 0.5 in point (500,500) i don't know the position of the bound and don't know how to calculate the anchor of new path the size and width(maybe just multiplied by the scale factor)
the function i want to implement like the viewport in svg
i think it should use coordinate mapping but how?
please give me some clue
I am going to implement a map application and I have a camerachange listener from which I can get the current zoom level. I would then set the polyline stroke width of the road to cover the width of roads in the map。 The problem is that I don't know what proper width I should set to polyline. Given that, is there any formal mapping methods or document in Android that can help me set a width per zoom level?
In my Android project im using mapquest data with OSMdroid. I would like to know what map scales the zoomlevels provide (e.g. 1:10000 etc.). I just found zoomlevel to scale depending on DPI (Is the map's scale also depending on the width and height of the map view, that I am showing?). If I use the mapquest map site, I just see a mapscale in the bottom left corner, but not in a ratio like 1:10000, which I actually need.
What are the scales 1:x at zoomlevel 16,15,14 ?
There are a few things going on here. Let me step through it as I understand it.
First, I believe what you are seeing in the Mapquest link is the ratio. So for zoomlevel 16,15,14:
14 = 1:27083
15 = 1:13541
16 = 1:6770
Although the link doesn't specify it, that should be in meters. So in zoom level 14, every pixel represents 27083 meters.
Additionally, the Bing maps ratios are found here. They are pretty close to the numbers that Mapquest reports, but they are not the same.
So, why are the numbers different? Because the meters-per-pixel ratio changes depending on what latitude you are at. Because of the distortion the Mercator projection produces, the meters-per-pixel is not constant as you change latitude. The Bing maps values are the values at the equator. I don't know where the Mapquest values come from.
Finally - to calculate meters-per-pixel in osmdroid you can call:
TileSystem.GroundResolution(latitude, zoomLevel);
And that will give you meters-per-pixel for a specific latitude. I recommend you take a look at osmdroid's ScaleBarOverlay for an example of how to apply this information.
Stay at the 0° latitude or the equatorial line (earth radius of 6372.7982km for the earth model of the map and equatorial circunference approximate as 40041.472km):
zoom level 0 represents 360° in a window (of 256px) which is on the equatorial line 40'041km
zoom 1 only 180° in the same window which is 20020km
zoom 2 is 90°, or 10010km
and so on always halving.
The scale (always speaking at the equatorial line) depends on the size of your window, if it is 1km wide, it is:
zoom 0 is 1:40041
zoom 1 is 1:20020
zoom x is 1:40041/2^x
etc
If the window is 1 inch wide:
zoom 0 is 1in:40041km or 1:1'576'417'322
zoom 10 is 1in:40041/1024km or 1:1'539'470
zoom 16 is 1:24054
If the window is 200px wide (for a 180 DPI screen):
zoom 0 is 200px:40041km or 1:1'418'775'590
zoom 18 is 200px:40041km/2^18 or 1:5412
This is just on the equatoriali line (0° latitude). In the north or south there is a correction factor to be applied, which is cos(latitude degrees).
i have 5 markers to display on the map, out of which 4 are very near to each other and the fifth one is a little bit distant to these 4. now when i display the map i want all these 5 markers to be shown on map and the with the highest possible zoom. i dont care whether they are on the border of the screen or in the center of the screen.i mean the markers can be scattered on the screen but all i want is that all markers should visible to the user and with the highest possible zoom.
i have tried this Android map v2 zoom to show all the markers . but the result is that it is showing all markers at the center of the map with very little zoom. actually i have calculated screen dimensions using this code.
DisplayMetrics metrics=new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
float height=metrics.heightPixels/metrics.xdpi;
float width=metrics.widthPixels/metrics.ydpi;
but i dont know why there is very little zoom. But wen i saw android documentation, i think the function is doing justice by doing whatever it said it will do.
public static CameraUpdate newLatLngBounds (LatLngBounds bounds, int width, int height, int padding)
Returns a CameraUpdate that transforms the camera such that the specified
latitude/longitude bounds are centered on screen within a bounding box of specified
dimensions at the greatest possible zoom level. You can specify additional padding,
to further restrict the size of the bounding box. The returned CameraUpdate has a
bearing of 0 and a tilt of 0.
Unlike newLatLngBounds(LatLngBounds, int), you can use the CameraUpdate returned by
this method to change the camera prior to the map's the layout phase, because the
arguments specify the desired size of the bounding box.
as it says it keeps all the markers at the center of the map. i do not want that. i want all the markers visible to the user with the maximum possible zoom and markers scattered. can anybody please help me?
Your calculation of float width and height is incorrect.
What your width holds now is inches (value of approx. 2 on phones). You need not to divide pixels width.
I am trying to make a map overlay that just shows a solid circle from the map center who's radius is a range in meters.
I can't figure out how to calculate the circle's radius. I can get the map center, but I haven't had any luck figuring out how to convert meters into the proper units for the circle's radius.
Thanks for any help.
I've got no experience of doing this in a gMaps context, but the MapView class (whose getProjection() I'm assuming you've used to work out where your point is on the screen) has getLatitudeSpan() and getLongitudeSpan() which you can use against the screen res to calculate the pixel-radius of your circle.