"Android" Gold map zoom levels and pixels and points on the map are converted to dots on the screen

Source: Internet
Author: User
Tags float range getcolor

/** *  adjust the map to all points that just place the query scope  *  @param  centerLatLng  Center point  *  @param  range   Query range (m)  */ private void adjustcamera (Latlng centerlatlng,int range)  {  //http://www.eoeandroid.com/blog-1107295-47621.html//the scale at the current zoom level  //"per pixel represents"  + scale +   "M" Float scale = g_amap.getscaleperpixel ();  //represents the number of pixels in range (m)  int pixel  = math.round (Range / scale),  //Small scale, small zoom level (large scale), with loss of precision  Projection  Projection = g_amap.getprojection ();  //converts the center point of the map to a point on the screen  Point center =  Projection.toscreenlocation (CENTERLATLNG);  //gets the left and right two points from the center point to pixel pixels (the point on the screen  point right =  new point (CENTER.X + PIXEL, CENTER.Y); point left = new  Point (CENTER.X - PIXEL, CENTER.Y);  //converts points on the screen to points on the map  latlng rightlatlng =  projection.fromscreenlocation (Right);  latlng leftlatlng = projection.fromscreenlocation (left); latlngbounds  Bounds = latlngbounds.builder (). Include (RIGHTLATLNG). Include (LEFTLATLNG). build ();//bounds.contains () ; G_amap.getmapscreenmarkers ();//Adjust visual range  //amap.movecamera (Cameraupdatefactory.newlatlngbounds ( Latlngbounds.builder (). Include (RIGHTLATLNG). Include (LEFTLATLNG). Build (),  10));  }}

Code snippet, click on the area to display the points on the area

LATLNG latlng = Marker.getposition ();//zoom level FLOAT zoom = G_amap.getcameraposition (). zoom;//"per pixel represents" + scale + "M" Float scal E = G_amap.getscaleperpixel (); Float range = scale * ZOOM; Circle Circle = g_amap.addcircle (New circleoptions (). Center (LATLNG). Radius (range). Strokecolor (Getresources (). GetColor (R.color.color_translate)). FillColor (Getresources (). GetColor (R.color.color_translate)). Strokewidth (2)) ;


"Android" Gold map zoom levels and pixels and points on the map are converted to dots on the screen

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.