So you have a ViewPager and your first page is an Android map. When you add or replace a new Fragment on the next page, your map resets when you go back to the first page.
Sadly, there is no way to retain its state. The only way you can do is to keep a reference on the map’s position by calling googleMap.getCameraPosition() and saving that in onSaveInstanceState() and restoring it in onCreate() or wherever.
Then you can reposition the map’s position and its zoom level by calling googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
So I created a set of LatLng objects and passed them to the PolylineOptions object in an Android Google Map and saw the resulting shape as a circle.
But the problem was the edges are not smooth. When I zoom in to the map, the circular shaped PolyLine looks good. However, when I zoom out, the smallest circle I had looked like an octagon.
So how to we go about creating a smooth circular PolyLine shape in Android Maps v2?
The only way to accomplish this is to make use of Android Map Utils CircleOptions. Just pass in a center LatLng object and the radius and voila! A smooth circle Polyline shape.
To get the center point of a set of LatLng objects, you need to pass all of them to a LatLngBounds object.
Once you have the LatLngBounds object, you can easily get the center point by calling getCenter(). The LatLngBounds class also has a variable called northeast that returns a LatLng object representing the north east point of the bounds.
What you need to do then is to get the distance between these 2 points which we will use as the radius of the circle.
We can accomplish this by placing the 2 LatLng points inside a Location object and calling the Location class’ distanceTo() method.
Java
1
2
3
4
5
6
7
8
9
10
11
12
LatLng center=bounds.getCenter();
LatLng northEast=bounds.northeast;
Location l1=newLocation("");
l1.setLatitude(center.latitude);
l1.setLatitude(center.longitude);
Location l2=newLocation("");
l2.setLatitude(northEast.latitude);
l2.setLatitude(northEast.longitude);
doubledistance=l1.distanceTo(l2);
That’s it! Add the LatLng center object to the CircleOptions class and set the distance as the radius of the circle.
Nowadays, there’s a lot of talk about outsourcing. Some people are quick to dismiss it for vague reasons, citing shaky examples about how it’s unfamiliar territory when it comes to the world of IT. The truth is, however, that outsourcing IT services is something that can be extremely beneficial to all parties involved.
Outsourcing IT services can not only be beneficial, but the option is becoming more and more accessible to small business owners, with outsourcing companies like Acora offering options to help small businesses get started. If you want to provide your company with IT services that won’t break the bank but will still help you to accomplish all of your business goals, then consider these reasons as to why outsourcing IT can actually be extremely positive.
Drastically Reduces IT And Labor Costs
The biggest benefit of outsourcing your IT services is the dramatic reduction in IT and labor costs that companies and their owners will enjoy. The price of domestic IT services is on the rise, whereas outsourced services haven’t risen in cost over the past few years. For any start-up that is looking to save money as it grows and expands, outsourcing IT services can be intensely beneficial. Small businesses need to cut costs wherever possible if they want to thrive and eventually expand.
Don’t Sacrifice Quality
Many people are operating under the erroneous belief that you sacrifice quality when you outsource your IT services. This couldn’t be any further from the truth. Outsourced IT workers are just skilled and knowledgeable as any domestic workers. In fact, in countries like India and China, many IT workers are actually ahead of domestic workers in terms of education and expertise. Considering that companies save money outsourcing in the first place, the high quality workers are just icing on the cake. Plus, technical support is just as good as any domestic company’s, which can be essential if businesses ever run into any IT hiccups.
Eliminate One Area That A Company Has To Worry About
Companies, especially new companies, already have enough on their plates. One of the simplest ways to make the life of a business owner easier is to remove something that they have to worry about. Outsourcing IT eliminates the amount of work that has to be done in-house. This is one of the many reasons why outsourcing IT makes company owners’ lives just so much easier.
Be A More Competitive Organization
Small businesses can enjoy the same level of quality IT services that their larger competitors enjoy when they choose to outsource. The business world is intensely competitive and it can be hard for smaller organizations to rise to the top. However, when a small business has the same quality IT support as a larger competitor, the playing field is evened.
It’s best not to listen to the naysayers who paint outsourcing as some sort of evil. Instead, small business owners should view it as a phenomenal way to save money while still enjoying quality labor, especially were IT services are concerned. By outsourcing IT, small businesses can really level the playing field and enjoy IT services that rival those of their competitors.