Comments (25)
I've tested png tiles yesterday, it works.
I can make MapView subclassable, no problem. Same for processHit, I can do that.
All of this will be available in 2.0.0
from mapview.
I'm polishing it before the release. All's left is the readme update. Should be done by this weekend.
from mapview.
Do you mean that you're not able to use 512x512 tiles?
Also, could you show me how you configure the MapView (I'd like to check).
from mapview.
Thanks for the quick reply! I am not able to use the 128x128 tiles, nor am I able to use the 512x512 tiles either. I thought maybe using smaller tiles would help fix the BitmapFactory warning.
Sure, here is the vips command I ran (mac)
vips dzsave /path/to/my/map.png path/to/android/assets/tiles --layout=google --tile-size=128 --suffix .png --vips-progress
here is the code from the onCreate
method in my Activity.
val mapView = MapView(this)
mapView.setBackgroundColor(resources.getColor(R.color.colorMapBackground, theme))
val config = MapViewConfiguration(levelCount = 7, fullWidth = 12876, fullHeight = 15624,
tileSize = 128, tileStreamProvider = MyTileStreamProvider(WeakReference(this.assets))
).setStartScale(1f)
.setMaxScale(2f)
.setMagnifyingFactor(1)
mapView.configure(config)
mapView.scale = 1f
findViewById<RelativeLayout>(R.id.map_container).addView(mapView)
this.mapView = mapView
and here is the code for MyTileStreamProvider
:
class MyTileStreamProvider(private val weakAssetManager: WeakReference<AssetManager>): TileStreamProvider {
override fun getTileStream(row: Int, col: Int, zoomLvl: Int): InputStream? {
return try {
val filename = "tiles/${zoomLvl}/${row}/${col}.png"
weakAssetManager.get()!!.open(filename)
} catch (e: Exception) {
e.printStackTrace()
null
}
}
}
Finally, here is the xml for the layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="MyApp.MyMainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/map_container"
>
<com.google.android.material.floatingactionbutton.FloatingActionButton .../>
<com.google.android.material.floatingactionbutton.FloatingActionButton .../>
</RelativeLayout>
</LinearLayout>
from mapview.
Alright, I'm going to check on that. For my information, have you tried the (default) 256 size?
from mapview.
I've found the issue. The tileSize property wasn't taken into account properly.
It's fixed in the version 1.0.8
Can you try it out and tell me if it's working for you?
A new major version of MapView is coming out soon. I'm going to integrate this fix into the next version.
from mapview.
awesome! I'll try it out tonight
from mapview.
Hmm - I haven't been able to get it to work.
I created a small demo project, with just the map and this MapView component in it. I added you as a collaborator.
from mapview.
Update - I switch from .png
to using .jpg
in vips
, and now the MapView component works!
from mapview.
Nice! When MapView 2.0.0 will be ready I will do a PR in your repo if you want.
Thanks for submitting this issue - it looks like you're the first one to try a different time size than 256.
from mapview.
is there any chance of supporting PNG?
And any plans for extensibility? Currently, MapView
isn't subclassable; and although MarkerLayout
is subclassable, its method processHit
isn't overridable. I want something that sends "processHit" to a callback with the current x, y, and zoom.
from mapview.
Thanks so much! Your library runs smoother than the library I'm migrating from. Looking forward to 2.0.0!
from mapview.
I've published the version 2.0.0-beta03
The API around map rotation isn't stable yet (It's working, but I might make changes).
2.x.x is a major shift from 1.x.x as it enables map rotation. It's only an opt-in feature, while configuring the MapView
, using enableRotation()
. The RotatingMapFragment
from the demo is an example. But I don't recommend that you use this for now.
Beware that there are some breaking changes. Most of the time, it's just a package name change.
The ScaleChangeListener
interface has been removed. If you relied on this, I can explain how to do the equivalent in 2.x.x
from mapview.
BTW, I'm closing this. Any feedback about the 2.0.0-beta will be appreciated (you can open other issues).
from mapview.
One bit of feedback: When the app loads, the map is blank until I scroll. This wasn't the case in 1.0.8
. I can't quite figure out if there is some way to make the map display without the user needing to scroll? Here is an example: https://github.com/danramteke/PLMapViewStudy/tree/upgrade-2.0.0
Other than that, this is wonderful! I'm able to get the tap information I need now that MapView
is subclassable
from mapview.
hmm I seem to have somehow gotten around the map loading as blank. I run a timer to poll if the map view has finished rendering, by comparing its height and width to 0
val config = MapViewConfiguration(...).setStartScale(0.5f)
mapView.configure(config)
Timer().schedule(object : TimerTask() {
override fun run() {
if (mapView.width != 0 && mapView.height != 0) {
mapView.scrollToDefaultLocation()
this.cancel()
}
}
}, 1, 5)
Thanks so much for this update!
from mapview.
Ok good to know. Thanks for the feedback.
from mapview.
from mapview.
@danramteke
I've been able to reproduce your issue with blank MapView in the beta. It was caused by the config setStartScale(1f). Any other scale would have worked.
It's fixed now, and I've published the version 2.0.0-beta04
Does this eliminates your need of callback?
BTW, I've created a "MapView 2.0.0 project" here: https://github.com/peterLaurence/MapView/projects/1
Do you have access to it?
Thanks again for your valuable feedback!
from mapview.
Hello, I updated to beta05, but I still need the timer to wait for the MapView to not have 0 width/height so that I can scroll to the default location in the viewport.
No worries though, the users I've talked to like the new MapView.
Yes, I have access to that project link.
from mapview.
from mapview.
It looks like your project has been removed. If I understood correctly, you need to scroll to a specific position as soon as the MapView is ready.
If I had to do this, I would do it inside onStart()
lifecycle of the fragment. But I can't be sure - ideally I should try your code.
from mapview.
I cannot reproduce your issue. If you look at MapAloneFragment
.. and if you do this:
...
return MapView(context).apply {
configure(config)
scale = 0.5f
scrollTo(3000, 3000)
}
It works as expected. I would recommend to follow the demo snippet as much as possible (adding the MapView inside onCreateView
, assign an id, etc.).
from mapview.
No worries, the people using my app are happy with how it's working. Thanks so much for your help!
Centering on default location
Yes it scrolls to the coordinates. The difference is that it scrolls to the top left corner instead of the center. A timer fixes this.
val mapView = MapView(context).apply {
configure(config)
scale = 0.5f
scrollTo(3000 - width/2.0, 3000 - height/2.0)
}
vs
val mapView = MapView(context).apply {
configure(config)
scale = 0.5f
}
// ...
Timer().schedule(object : TimerTask() {
override fun run() {
if (mapView.width != 0 && mapView.height != 0) {
this.cancel()
scrollTo(3000 - mapView.width/2.0, 3000 - mapView.height/2.0)
}
}
}, 1, 5)
Using onStart
Callback
Also, I looked into onStart
and that won't work for me since onStart
is called every time the app comes back from the background.
Sample project
Hmm - not sure why it's missing. There's a lot of things I need to take care of today. If I have time, I'll look into why it's missing.
from mapview.
Thank you for this detailed answer. Now I understand the confusion. I've pushed a new branch [bounds](https://github.com/danramteke/PLMapViewStudy/tree/bounds)
It shows you how to scroll to a percent of the map's width and height, not using a timer and right after the configuration.
from mapview.
Related Issues (20)
- Refresh map tiles HOT 7
- Redraw map tiles HOT 3
- Marker callout disappeared when clicking or moving map view HOT 1
- No tiles visible, ability to center? HOT 1
- Marker size when changing the zoom level HOT 3
- BufferOverflow on Channel coroutine HOT 3
- MarkerView is not removed from the MapView HOT 5
- rectangular tiles HOT 1
- scrollTo / scrollToAndCenter using different coordinates after scaling HOT 6
- Can you support drawing points? HOT 2
- Draw polygon HOT 1
- BitmapFactory: bitmap marked for reuse HOT 3
- Non-existent zoom on an overlay. HOT 21
- Clear memory HOT 2
- maker cant be moved as MapCompose HOT 1
- can you support Marker Drag? HOT 4
- Mini gaps between tiles HOT 2
- How to click or long click on map to add marker.
- Support for .png deep zoom map
- bitmap marked for reuse can't fit new bitmap error (100% reproducible) for Remote HTTP mapview HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapview.