Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading an image from an URL in to customInfoWindow Google Maps

am implementing google maps with custom info window. the window works fine, but for some reason, the image is not loading into my imageView. I don't see any errors also.

I am trying to load the image from URL into the imageView inside the custom marker info window

enter image description here

I want to load the image to the top. The image url Look like this. https://lh3.googleusercontent.com/p/AF1QipNP6n3JeoWAWo8WhS7-RTC0e3o-R04EUx7gJeOX=s1600-w1400

Java

  @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;

        mMap.getUiSettings().setZoomControlsEnabled(true);


        LatLng snowqualmie = new LatLng(Double.parseDouble(Latitude), Double.parseDouble(Longitude));

        MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.position(snowqualmie)
                .title(Name)
                .snippet(Description)
                .icon(BitmapDescriptorFactory.defaultMarker( BitmapDescriptorFactory.HUE_BLUE));





        mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {



            @Override
            public View getInfoWindow(Marker marker) {
                return null;
            }



            @Override
            public View getInfoContents(Marker marker) {
                View view = getLayoutInflater().inflate(R.layout.map_info_window, null);
                final ImageView infoImage = view.findViewById(R.id.info_image);
                TextView InfoName = view.findViewById(R.id.info_tv_name);
                TextView Lati = view.findViewById(R.id.Info_latitude);
                TextView Longi = view.findViewById(R.id.info_longitude);
                TextView Addres = view.findViewById(R.id.info_address);
                TextView Desc = view.findViewById(R.id.info_description);

                TextView msg_Address = findViewById(R.id.tv_msg_address);
                TextView msg_Description = findViewById(R.id.tv_msg_description);

                InfoName.setText(MapDisplay.Name);
                Lati.setText(MapDisplay.Latitude);
                Longi.setText(MapDisplay.Longitude);

                Picasso.with(context)
                        .load(Uri.parse(MapDisplay.ImageURL))
                        .fit().centerCrop()
                        .into(infoImage);

                    if (MapDisplay.Address == "" || MapDisplay.Address == null || MapDisplay.Address.length() == 0){
                        Addres.setText("No address added.");
                    }else {
                        Addres.setText(MapDisplay.Address);
                    }


                    if (MapDisplay.Description == "" || MapDisplay.Description == null || MapDisplay.Description.length() == 0){
                        Desc.setText("No description added.");
                    }else {
                        Desc.setText(MapDisplay.Description);
                    }

                return view;
            }
        });

        googleMap.setOnInfoWindowClickListener(this);


//        // Add a marker in Sydney and move the camera
        LatLng Location = new LatLng(Double.parseDouble(Latitude), Double.parseDouble(Longitude));
        mMap.addMarker(new MarkerOptions().position(Location).title(Name));
        mMap.moveCamera(CameraUpdateFactory.newLatLng(Location));
        CameraPosition cameraPosition = new CameraPosition.Builder().target(Location).zoom(16).build();
        mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));


    }

Can someone help me to fix this. tnx

like image 816
Sathya Baman Avatar asked Dec 19 '25 22:12

Sathya Baman


1 Answers

Try removing the Picasso's

.fit().centerCrop()

Control the image view size, scaling attributes via XML, where you defined the imageView ("info_image")

like image 146
Niroshan Avatar answered Dec 22 '25 12:12

Niroshan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!