amal-kronz-orch / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

How to implement ballons overlay? #276

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I sucessfully have implemented OnTouchEvent which respond to Drag/Drop of 
overlays.  However, how can I add a ballonoverlay to an overlay item? Any 
suggestion? I has been trying modify android-mapviewballoons 
(https://github.com/jgilfelt/android-mapviewballoons) which work with Google 
Map but still is not working for me.

Original issue reported on code.google.com by kako1...@gmail.com on 23 Nov 2011 at 7:36

GoogleCodeExporter commented 9 years ago
This is not really a bug, but since you've pointed out something that I'm 
probably going to make use of I thought I'd share my first attempt at making it 
work. (currently I can't actually close the balloons once they open though)

I've edited BalloonItemizedOverlay to use osmdroid classes and added a few 
little hacks which I've attempted to comment. 

I suggest you compare it to the original at
https://github.com/jgilfelt/android-mapviewballoons/blob/master/android-mapviewb
alloons/src/com/readystatesoftware/mapviewballoons/BalloonItemizedOverlay.java 
.. and open a thread on the discussions as I imagine this will be closed pretty 
quick!

Original comment by t...@chellew.co.uk on 21 Mar 2012 at 7:16

Attachments:

GoogleCodeExporter commented 9 years ago
I've successfully modified MarkersOverlayWithFocus to display a modified 
BalloonOverlayView (from 
https://github.com/jgilfelt/android-mapviewballoons/blob/master/android-mapviewb
alloons/src/com/readystatesoftware/mapviewballoons/BalloonOverlayView.java).

The code is for use within a Basic4Android project so i can't post working 
native Android SDK example but i'll attach my MyItemizedOverlayWithFocus and 
MyBalloonOverlayView classes.

You can hopefully follow my logic.

It all works well but the focused OverlayItem is no longer always drawn last 
(so that it appears upper most of all OverlayItems), i'm trying to fix that now.

Original comment by warwo...@gmail.com on 15 Apr 2012 at 11:28

Attachments:

GoogleCodeExporter commented 9 years ago
Oooops i meant "I've successfully modified ItemizedOverlayWithFocus" and NOT 
"I've successfully modified MarkersOverlayWithFocus".

Original comment by warwo...@gmail.com on 15 Apr 2012 at 11:30

GoogleCodeExporter commented 9 years ago

Original comment by neilboyd on 15 Apr 2012 at 3:07

GoogleCodeExporter commented 9 years ago
Does anyone have a generic solution?  Comments 2 and 3 did not work for me

Original comment by jyee.dis...@onescreen.com on 3 May 2012 at 1:22

GoogleCodeExporter commented 9 years ago
My posted solution was originally developed to use within Basic4Android and i 
don't have the time to create a native Android example.
But let me try and help.

First look at MyBalloonOverlayView class:
http://android.martinpearman.co.uk/b4a/osmdroid/src/uk/co/martinpearman/b4a/osmd
roid/views/overlays/MyBalloonOverlayView.java

This is a much modified version of the BalloonOverlayView class that can be 
found here:
https://github.com/jgilfelt/android-mapviewballoons/blob/master/android-mapviewb
alloons/src/com/readystatesoftware/mapviewballoons/BalloonOverlayView.java

I'm basically creating a FrameLayout with setters to set the balloon label text.

Then i have my MyItemizedOverlayWithFocus class, a much modified version of the 
similarly named OSMDroid class:
http://android.martinpearman.co.uk/b4a/osmdroid/src/uk/co/martinpearman/b4a/osmd
roid/views/overlays/MyItemizedOverlayWithFocus.java

In one of the constructors i create an instance of MyBalloonOverlay and add it 
to the map.

Then in MyItemizedOverlayWithFocus's draw method i check to see if an 
OverlayItem is focused and show or hide the MyBalloonOverlayView accordingly.

Works well and performs well - easily handles 100+ OverlayItems on a modest 
single core device such as my ZTE Blade.

You won't be able to copy n paste my code i think but have a look through it 
for some ideas.

Original comment by warwo...@gmail.com on 4 May 2012 at 4:53

GoogleCodeExporter commented 9 years ago
What is b4a and why don't you simply develop for general Android SDK so that 
everyone can use it ? ;/

Original comment by blindsc...@gmail.com on 11 May 2012 at 11:36

GoogleCodeExporter commented 9 years ago
Also, can someone show me their class where these are implemented? e.g. 
MainActivity.java

Because I can't seem to get it working...

Original comment by blindsc...@gmail.com on 11 May 2012 at 12:05

GoogleCodeExporter commented 9 years ago
For anyone that's starred this request we have a new option:

http://code.google.com/p/osmbonuspack/

I haven't tested it yet but it looks good.

Original comment by warwo...@gmail.com on 8 Jun 2012 at 1:06