Git Product home page Git Product logo

mapview's People

Contributors

moagrius avatar shusshu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mapview's Issues

outOfMemory on galaxy S3 (Log errors but no crash)

I get a lot of out of memory on a Galaxy S3.

I don't know yet how it really happens but my guess is that it's linked to device rotation & putting the app in the background and then switching back to it (via long press on home button)

map doesn't redraw after scrolling if scale is greater than 1

I found a patch that works for me in an specific case, and I want to share it with you, MapView users.

I need to have max scales bigger than 1.
When I patch both same lines in ZoomManager.java and ZoomPanLayout.java:

private double maxScale = 4;

everything works fine, but at some point, only when scale is greater than 1, the map tiles will not be drawn after scrolling the map.

I patched TileManager, adding invalidate() at the end, and this solved the problem:

void onRenderTaskPostExecute() {
    // set flag that we're done
    isRendering = false;
    // everything's been rendered, so get rid of the old tiles
    cleanup();
    // recurse - request another round of render - if the same intersections are discovered, recursion will end anyways
    requestRender();
    // notify anybody interested
    if ( renderListener != null ) {
        renderListener.onRenderComplete();
    }
    invalidate();
}

TileManager leaks on orientationchange

TileManager will leak on orientation change.
The reason for memory leak is inner class of Handler instance. This should be static.

Example solution would be.

static private Handler handler = new Handler() {
@OverRide
public void handleMessage(final Message message)
{
switch ( message.what ) {
case RENDER_FLAG :
TileManager manager = (TileManager)message.obj;
manager.renderTiles();
break;
}}};

public void requestRender() {
    // if we're requesting it, we must really want one
    renderIsCancelled = false;
    renderIsSuppressed = false;
    // if there's no data about the current zoom level, don't bother
    if ( zoomLevelToRender == null ) {
        return;
    }
    // throttle requests
    if ( handler.hasMessages( RENDER_FLAG ) ) {
        handler.removeMessages( RENDER_FLAG );
    }
    // give it enough buffer that (generally) successive calls will be captured
    Message message = handler.obtainMessage(RENDER_FLAG, this);
    handler.sendMessageDelayed(message, RENDER_BUFFER);
}

Intersection callculation issue

I think that intersection is not calculated correctly. In zoomlevel.java
you are scaling tile size(tileWidth * scale) but using basemap size to calculate tile row/column.

Updated version of method below:

public LinkedList<MapTile> getIntersections() {
int zoom = zoomManager.getZoom();
double scale = zoomManager.getRelativeScale();
double offsetWidth = tileWidth * scale;
double offsetHeight = tileHeight * scale;
LinkedList<MapTile> intersections = new LinkedList<MapTile>();
Rect boundedRect = new Rect( zoomManager.getViewport() );
boundedRect.top = Math.max( boundedRect.top, 0 );
boundedRect.left = Math.max( boundedRect.left, 0 );
boundedRect.right = Math.min( boundedRect.right, (int)(mapWidth*scale) );
boundedRect.bottom = Math.min( boundedRect.bottom, (int)(mapHeight*scale) );
int sr = (int) Math.floor( boundedRect.top / offsetHeight );
int er = (int) Math.ceil( boundedRect.bottom / offsetHeight );
int sc = (int) Math.floor( boundedRect.left / offsetWidth );
int ec = (int) Math.ceil( boundedRect.right / offsetWidth );
for ( int r = sr; r < er; r++ ) {
for ( int c = sc; c < ec; c++ ) {
MapTile m = new MapTile( zoom, r, c, tileWidth, tileHeight, pattern );
intersections.add( m );
}
}
return intersections;
}

ZoomLevels not in order

Zoom levels are sorted by area ( mapWidth*mapHeight). The result for huge maps does not fit into integer. E.g square map which is larger than 46341px.

Adding ZoomLevels dynamically does not allow zooming.

Adding ZoomLevels dynamically through buttons and spinners does not re-calculate the available scale, which in turn allows only panning and not zooming. The issue persists through resetZoomLevels() as well. An additional example is if a default map is loaded and then replaced with a smaller set of tiles, the mapview allows zooming beyond the limits of the new tileset.

I tried finding the cause, but had no luck. I believe that the issue might be that all layouting and drawing methods only happen once during runtime and changes made after do not re-calculate the scale.

Edit: Using setScaleToFit(true) causes the ZoomPanLayout to calculateMinimumScaleToFit() thereby allowing zoom again.

Loading downsample via TileDecoder

Hi there,

first, thanks! Great component.

I wrote a TileDecoder to load tiles from the file system, as our map gets downloaded and stored locally.
It would be cool, if the downsample could be loaded through the same method as the tiles.

Cheers,
Alex

Mismatch between x & y values

It appears that in PathView.java the drawPath(List points) method has mistake regarding some x and y coordinates.

The line (71) reads:
originalPath.moveTo( (float) start.x, (float) start.x );

I believe it should be:
originalPath.moveTo( (float) start.x, (float) start.y );

Render tiles outside of view

Other applications such as google maps and osmdroid usually render the tiles which are not shown on screen but are "close" the the ones shown. It would be very useful to provide with an option to choose how many adjacent tiles should be rendered.

I also noticed that if the user drags around the map, unrendered tiles are not rendered until the user lifts the finger. Probably the application should check which tiles should be rendered while the map moves, and not when the user completes the drag. It would greatly improve the responsiveness feeling.

fatal exeption while registering geolocator

i get this error when i try to register geolocator:

01-30 12:18:05.580: E/AndroidRuntime(4586): FATAL EXCEPTION: main
01-30 12:18:05.580: E/AndroidRuntime(4586): java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
01-30 12:18:05.580: E/AndroidRuntime(4586): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
01-30 12:18:05.580: E/AndroidRuntime(4586): at java.util.ArrayList.get(ArrayList.java:304)
01-30 12:18:05.580: E/AndroidRuntime(4586): at com.qozix.map.zoom.ZoomManager.getZoomLevel(ZoomManager.java:92)
01-30 12:18:05.580: E/AndroidRuntime(4586): at com.qozix.map.MapView.registerGeolocator(MapView.java:232)

do you have a idea how to make it work?

Markers moving when zooming

My markers do not stay in the same place when I zoom on the map.
As I zoom out they more further and further away from their original position.

Map created with:

mapView.setBackgroundColor(Color.BLACK);
mapView.setMarkerAnchorPoints(0.5f, 1f);
mapView.setShouldIntercept(true);
mapView.setCacheEnabled(true);

Marker inserted as:

mapView.addMarker(createMarkerView(this, "TEST"), 500, 500);

The createMarkerView function:

private ImageView createMarkerView(final Context context, final String title) {
        ImageView imageView = new ImageView(context);
        imageView.setImageResource(R.drawable.current_position);
        imageView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Logging.toast(context, title);
            }
        });

        return imageView;
}

refactor as an Android library

Hi,

Would you mind if I refactor this project in order to be structured as an Android library ?

And also if I would mavenise it ?

Tiles takes more time to get displayed

I know you improved performances and avoid possible outOfMemoryException's but now the tiles takes way more time to load.

I didn't look how you deal with this yet...

Callout drawn off screen

Hi,

I've implemented a callout very similar to your example. When the callout is positioned near the top of the image held in the MapView parts of the callout will be drawn off the screen and therefore not visible.

In order to solve this, I could add some white space around the image I'm trying to draw but just thought I'd check if there are any better solutions.

Thanks for your work.

Need an example

Hey, this thing looks awesome but I need more info on how to use it!

In particular things I dont understand:

mapView.addOnReadyRunnable(someRunnable);
mapView.addOnReadyRunnable(anotherRunnable);

What are these runables and why are they added?

mapView.setMapEventListener(someMapEventListener);

whats this an why is it added?

mapView.addZoomLevel(6180, 5072, "tiles/boston-1000-%col%_%row%.jpg","downsamples/boston-pedestrian.jpg", 256, 256);

what is the downsampled image all about?

If you could provide a working sample of this in action I think it would be much nicer to understand.

Thanks ! Im hoping I can use this for my current app.

removed downsample

google maps uses a layout that has a tile background. it is implemented as a theme so it doesn't need time to load and people see from the start a background with loading images that are as big as the actual tiles.

i think it would be nice to implement this strategy as well.

when i think about it, is it possible for me to add a custom layout to mapview at this point?

Positioning of markers when zooming

Hi,

My colleague and I have rewritten a bit of your code which places markers on the marker layer. We've adapted it so that the coordinates passed to addMarker(view, x, y) represent the center of where the view should be placed, instead of it being the top left corner. Also, we've adjusted the way the marker is placed when zooming the map so that the position of the marker remains the same (previously it was moving a little bit).

Please find the adapted code below (from TranslationLayer.java):

@Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        int count = getChildCount();
        for (int i = 0; i < count; i++) {
            View child = getChildAt(i);
            if (child.getVisibility() != GONE) {
                LayoutParams lp = (LayoutParams) child.getLayoutParams();
                int w = child.getMeasuredWidth();
                int h = child.getMeasuredHeight();
                int newL = lp.x - (w / 2);
                int newT = lp.y - (h / 2);
                int scaledX = (int) (0.5 + (newL * scale));
                int scaledY = (int) (0.5 + (newT * scale));
                int y = scaledY - (int) (h * (1 - scale));
                int x = scaledX - (int) ((w / 2) * (1 - scale));
                child.layout(x, y, x + w, y + h);
            }
        }
    }

Lastly, we've removed the part where the anchors were handled, since we couldn't figure out exactly what this was supposed to do. It seemed to me that it the previous code just moved the marker one image length to the left and one image height to the top if no anchors where set.

Hopefully this is helpful for a future release.

Feature Requests

There are a number of API-breaking changes I'd like to make, as well as the project rename discussed earlier, which will effectively require a new repo. I'll continue to maintain this repo for a while, with the goal of eventually moving everything over to TileView.

Please use this thread for any feature requests or enhancements, even if they'd break the existing API. Thanks.

Map Landscape (Rotation)

The map does not load completely on the far right in the furthest zoom level

I got 2 cases for this:

If I'm zoomed in and go to far right the map loads then I zoom out completely the right part of the map never loads and we see white imgs.

On the other hand if I am zoomed in the centre of the map and zoom out completely the map is smaller than it should it does not show the white imgs and never load them

This only happens in landscape

add low res background image capability

It would be a great idea to display a low res image background while tiles are loading in order not to loose a "visible reference".
It should work like the downsample in the previous version but with the same image for all zoom levels.

expose lockZoom and unlockZoom

locking prevents the tile sets from updating. This can be very helpful for actions like updating scale from a scratch action or animation. At the end of the action, unlock it to get the appropriate tile set.

Not all zoom levels available

Hi,

I'm having an issue with zooming the map in portrait mode. My map has three zoom levels but I can only use two of the zoom levels in portrait mode, the lowest zoom level doesn't work. When I rotate the phone to landscape mode, all zoom levels are available. This problem occurred on an HTC One X and a Samsung Galaxy S3. On a HTC Sensation and a HTC Desire the zoom levels do work correctly in portrait mode. Any idea what might cause this?

slideToAndCenter randomly not works

In addition to #19 und #20 I'd like to re-open this issue.

I'm working with the MapView in a fragment. When starting the map fragment MapView should slideToAndCenter to a given position. This always works well.

In addition I have a 'center' button which can be touched. In the buttons onClick Listener I do another slideToAndCenter.

This randomly works or fails.
When the Map is rendered and I touch the button nothing happens.
When the Map is still rendering (i.e. touching the button shortly after swiping on the map when some tiles aren't rendered yet) the map slides to the position.

Image moving between zoom levels

Hi,

I believe this may be a bug in my implementation of the MapView rather than a bug with the controller itself but I thought I'd post to see if anyone else has had a similar issue.

I've created the tiled images for 4 different resolutions of an image these are loaded into the MapView controller and markers positioned over the top. The markers are positioned correctly for the highest zoom level but as you zoom out and change zoom levels (and therefore tileset) the image appears to jump/move so you will no longer be centered around the same point. Consequently the markers are not longer positioned in the corrected place in relation to the map. Just to clarify, when zooming across a zoom level the markers stay in the correct position in relation to the screen but the map appears to shift beneath them resulting in markers being incorrectly positioned.

Has anyone come across this before? Thanks in advance.

Phil

Centering the map

I have a flat map that is in its smallest zoom level much smaller than the size of the MapView Container. Right now, the MapView container just draws the map from the top-left corner, which leads to a lot of empty space on the rest of the screen. Would it be possible to center the map?

Project Rename

I feel like the name "MapView" is too ambiguous, not really accurate (the widget could be used for many non-map type apps), and is confusing when considering the very common and popular google maps MapView.

I'm considering renaming the project to "TiledLayer". Obviously the package and class names would be updated to reflect the new project name.

I'm posting this as an "issue" for any input one way or the other - does anyone have a problem with this, or opinion either way?

Thanks.

intercepting gestures in mapview/touchlayer

would you mind helping me with another issue?

my markers/overlays (RelativeLayout) have an onclick listener on a child (ImageView) inside.
when i try to drag the map, and the finger is on a marker, the marker consumes the event and doesn't pass it to the map.

as far as i understand it, i have two options:

  1. stop event propagation in TouchLayer
  2. intercept event in my marker.

what do you think?

redrawing map after moveToAndCenter()

i noticed when using moveToAndCenter() the downsampled image stays visible and the map isn't redrawing.

you're aware of this? you have a tip on how to fix that?

Extra zoom feature

Would it be possible to implement possibility to zoom over the maxzoom. I would mean to go with scale over 1.0 for max zoom. The reason is that on Galaxy S4, which has FullHD display, the pixels are very small and max zoom doesn't seem to be enough.

How to use from XML?

Hey, programatically its working pretty good, but how do I load from XML? I tried this:

<com.qozix.map.MapView
    android:id="@+id/mymap"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
</com.qozix.map.MapView>

And the error:

java.lang.RuntimeException: Unable to resume activity {thrillseeker.app.paultons/thrillseeker.app.paultons.activities.ScrollingMapActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class com.qozix.map.MapView
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2120)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2135)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.qozix.map.MapView
at android.view.LayoutInflater.createView(LayoutInflater.java:508)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:857)
at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:218)
at thrillseeker.app.paultons.activities.ScrollingMapActivity.onResumeX(ScrollingMapActivity.java:37)
at thrillseeker.app.silverputty.view.SilverActivity.onResume(SilverActivity.java:808)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
at android.app.Activity.performResume(Activity.java:3832)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2110)
... 12 more
Caused by: java.lang.NoSuchMethodException: MapView(Context,AttributeSet)
at java.lang.Class.getMatchingConstructor(Class.java:643)
at java.lang.Class.getConstructor(Class.java:472)
at android.view.LayoutInflater.createView(LayoutInflater.java:480)
... 24 more

setZoom does nothing in the UI

Maybe it needs a refresh ?

I guess it is telling the system it needs to take imgs from that zoom level and that's it?

Changing ZoomLevels

Hi,

I'm looking to change the zoom levels used in the MapView throughout it's life. Do you know of a way of doing this?

I've added a couple of zoomlevels through the addZoomLevel method but I'd then like to remove all the zoom levels and add a new set pointing at a different set of tiles - what would be the best way of doing this? Currently I am creating a new MapView object each time the zoomlevels need to change.

Thanks

onInterceptTouchEvent

The behavior before was better as it was easy to press on a point and get a popup or an action.
now the map moves on touch instead of getting to the point

License

Would it be possible to change the license to a more common OS license like Apache License 2.0 or any other of the list http://opensource.org/licenses?
I would like to use the MapView in a commercial project and I don't know what the implications of the CCPL license are.

marker issue

i manage the layout of my markers inside the marker, since they are a little complex.

so i had to set set AnchorLayout.setClipChildren(false).
the problem is, when a childview in my marker is positioned outside the bounds of the marker, it isn't clickable anymore.

this behavior changed since the prvious version. any idea why?

i attached a image to illustrate it: the dark rectangle shows the bounds of my marker. the pin is a child of marker, the green and red dots are only to show where i click.
when i click the green touchpoint the click is registred, the click on the red point does nothing.
Screenshot_2013-03-12-14-10-32

Huge map loading time

I have a map which is 150x150 tiles. I takes over 15 secs to create list of MapTiles in TilesLayer - update.
While zooming previous maplevel level is removed from the view and screen is gray while new level is loading.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.