Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8790725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:43:51+00:00 2026-06-13T22:43:51+00:00

I am using mapview in my android app using the class com.google.android.maps I wont

  • 0

I am using mapview in my android app
using the class com.google.android.maps
I wont lo load markers using background process when the user navigate I want to
send the Viewport coordinate to my server
I can do it in javascript like here

 google.maps.event.addListener(map, 'idle', showMarkers);
  function showMarkers() {
var bounds = map.getBounds();

// Call you server with ajax passing it the bounds

// In the ajax callback delete the current markers and add new markers

}

But how can I do this in java ? Please suggest.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:43:52+00:00Added an answer on June 13, 2026 at 10:43 pm

    i post this answer and i hope to save some one else time
    i found that the best solution for my case is to use custom map view SimpleMapView
    first crete the SimpleMapView class in your project and here is the code

    import java.util.ArrayList;
    import java.util.List;
    
    import android.content.Context;
    import android.graphics.Canvas;
    import android.util.AttributeSet;
    import android.view.MotionEvent;
    
    import com.google.android.maps.GeoPoint;
    import com.google.android.maps.MapController;
    import com.google.android.maps.MapView;
    
    
    
    
    public class SimpleMapView extends MapView {
    
        private int currentZoomLevel = -1;
        private GeoPoint currentCenter;
        private List<ZoomChangeListener> zoomEvents = new ArrayList<ZoomChangeListener>();
        private List<PanChangeListener> panEvents = new ArrayList<PanChangeListener>();
    
        public SimpleMapView(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
        }
    
        public SimpleMapView(Context context, String apiKey) {
            super(context, apiKey);
        }
    
        public SimpleMapView(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
        /**
         * 
         * @return
         */
        public int[][] getBounds() {
    
            GeoPoint center = getMapCenter();
            int latitudeSpan = getLatitudeSpan();
            int longtitudeSpan = getLongitudeSpan();
            int[][] bounds = new int[2][2];
    
            bounds[0][0] = center.getLatitudeE6() - (latitudeSpan / 2);
            bounds[0][1] = center.getLongitudeE6() - (longtitudeSpan / 2);
    
            bounds[1][0] = center.getLatitudeE6() + (latitudeSpan / 2);
            bounds[1][1] = center.getLongitudeE6() + (longtitudeSpan / 2);
            return bounds;
        }
    
        public boolean onTouchEvent(MotionEvent ev) {
            if (ev.getAction() == MotionEvent.ACTION_UP) {
                GeoPoint centerGeoPoint = this.getMapCenter();
                if (currentCenter == null || 
                        (currentCenter.getLatitudeE6() != centerGeoPoint.getLatitudeE6()) ||
                        (currentCenter.getLongitudeE6() != centerGeoPoint.getLongitudeE6()) ) {
                    firePanEvent(currentCenter, this.getMapCenter());
                }
                currentCenter = this.getMapCenter();
            }
            return super.onTouchEvent(ev);
        }
    
        @Override
        protected void dispatchDraw(Canvas canvas) {
            super.dispatchDraw(canvas);
            if(getZoomLevel() != currentZoomLevel){
                fireZoomLevel(currentZoomLevel, getZoomLevel());
                currentZoomLevel = getZoomLevel();
            }
        }
    
        @Override
        public void setSatellite(boolean on){
            super.setSatellite(on);
        }
    
        @Override
        public MapController getController(){
            return super.getController();
        }
    
        private void fireZoomLevel(int old, int current){
            for(ZoomChangeListener event : zoomEvents){
                event.onZoom(old, current);
            }
        }
    
        private void firePanEvent(GeoPoint old, GeoPoint current){
            for(PanChangeListener event : panEvents){
                event.onPan(old, current);
            }
        }
    
        public void addZoomChangeListener(ZoomChangeListener listener){
            this.zoomEvents.add(listener);
        }
    
        public void addPanChangeListener(PanChangeListener listener){
            this.panEvents.add(listener);
        }
    }
    

    and in your mapactivity just make

     SimpleMapView mapView = (SimpleMapView) findViewById(R.id.mapView);
    

    and then you have

        mapView.addPanChangeListener(new PanChangeListener() {
    
        @Override
        public void onPan(GeoPoint old, GeoPoint current) {
                      //TODO
                  //do your work here 
    
                    }
    });
    

    and add the PanChangeListener class here the code

    package yourPkageName;
    
    import com.google.android.maps.GeoPoint;
    
    public interface PanChangeListener {
        public void onPan(GeoPoint old, GeoPoint current);
    }
    

    and add the ZoomChangeListener class here the code

    package yourPkageName;
    
    public interface ZoomChangeListener {
        public void onZoom(int old, int current);
    }
    

    and in your xml file add

    <?xml version="1.0" encoding="utf-8"?>
    
    <YourPakageName.SimpleMapView   xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:apiKey="0mAbU5bZyFY2I46PFJ1ysXGcYlAmFM6fYBWSB7Q"
        android:clickable="true" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a com.google.android.maps.MapView in my application. When using the normal view I do
I am using the following map class to use maps in my android app...
It is well know to people using Google Maps in an Android app that
I'm using the following tutorial http://developer.android.com/resources/tutorials/views/hello-mapview.html in order to create a map view and
I was trying a quick tutorial using google maps in Andriod When I load
So i've been building an app using Google Maps API and i've run into
I'm using http://developer.android.com/resources/tutorials/views/hello-mapview.html#top tutorial to show multi location in the map using markers.but it
I have an Android Activity that displays Google Maps through MapView control and extending
I'm using a Google API MapView in my Android application and I've discovered it
I'm making an app for android, I'm using Google Directions API to get and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.