Description: I am making a small application that displays markers but there is a problem with using JSON.
Problem: I do not understand how to transfer data from a file, for later creating markers based on them. Most of the examples I found were for transferring data from sites (I am new to Android for Android studio here:
.json:
{ "markerss":[ { "title": "West", "lat": 53.223798, "lng": 44.889040, "snippet": "placeinformation2010" }, { "title": "East", "lat": 53.2220, "lng": 44.8799, "snippet": "placeinformation102" } ] } .java:
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { GoogleMap mMap = null; private static final LatLng place1 = new LatLng(53.223798, 44.889040); private static final LatLng place2 = new LatLng(53.2220, 44.8799); // Решил попробовать сделать перемененные для последующей и работы ,тип ближайшей Marker mPlace1; Marker mPlace2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); // Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(map); mapFragment.getMapAsync(this); } @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.moveCamera(CameraUpdateFactory.newLatLngZoom( new LatLng(41.889, -87.622), 10)); // Создание маркеров и подробная их подробная информация mPlace1 = mMap.addMarker(new MarkerOptions() .position(place1) .title("West") .anchor(0.0f, 1.0f) .icon(BitmapDescriptorFactory.fromResource(R.drawable.kebab)) .snippet("dsf")); mMap.moveCamera(CameraUpdateFactory.newLatLng(place1)); mPlace2 = mMap.addMarker(new MarkerOptions() .position(place2) .title("East") .anchor(0.0f, 1.0f) .icon(BitmapDescriptorFactory.fromResource(R.drawable.kebab)) .snippet("edfjk")); mMap.moveCamera(CameraUpdateFactory.newLatLng(place2)); } }