new MapMarker problem
Bitmap bitmap = BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.marker);
marker = new MapMarker(this, pos, MapControlAlignmentType.CenterBottom, bitmap);
var popupView = marker.AddNewPopup(300, 300);
var textView = new TextView(this.ApplicationContext);
textView.Text = "Some popup text here: " + idx.ToString() + " / \n Loc" + marker.Location.ToStringEmptyWhenNull();
textView.TextSize = 10;
textView.SetTextColor(global::Android.Graphics.Color.LightBlue);
textView.SetBackgroundColor(global::Android.Graphics.Color.DarkGray);
popupView.AddView(textView);
_mapView.AddMarker(marker);
markerList.Add(marker);
The marker never visible on the map. It is a Bug?
this issue seems to be on android only from what i have been finding.
Seems like I am experiencing the same issue. Did You found a solution ? My code so far is :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using OsmSharp.Android.UI;
using OsmSharp.UI.Map;
using OsmSharp.UI.Map.Layers;
using OsmSharp.Math.Geo;
using Android.Graphics;
using OsmSharp.Android.UI.Controls;
namespace Android.Demo
{
[Activity(Label = "Online Tiles Demo")]
public class TilesActivity : Activity
{
private MapView _mapView;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// hide title bar.
this.RequestWindowFeature(global::Android.Views.WindowFeatures.NoTitle);
// initialize map.
var map = new Map();
map.AddLayer( new LayerTile( "http://a.tile.openstreetmap.org/{0}/{1}/{2}.png", 160 ) );
// define the mapview.
var mapViewSurface = new MapViewSurface(this);
mapViewSurface.MapScaleFactor = 2;
_mapView = new MapView(this, mapViewSurface);
_mapView.Map = map;
_mapView.MapMaxZoomLevel = 18; // limit min/max zoom because MBTiles sample only contains a small portion of a map.
_mapView.MapMinZoomLevel = 0;
_mapView.MapTilt = 0;
_mapView.MapCenter = new GeoCoordinate( 43, 24 );
_mapView.MapZoom = 12;
_mapView.MapAllowTilt = false;
// set the map view as the default content view.
SetContentView(_mapView);
Bitmap bitmap = BitmapFactory.DecodeResource( this.Resources, Resource.Drawable.Icon );
var marker = new MapMarker( this, new GeoCoordinate( 43, 24 ) );//, MapControlAlignmentType.CenterBottom, bitmap );
_mapView.AddMarker( marker );
}
protected override void OnDestroy()
{
base.OnDestroy();
OsmSharp.Logging.Log.TraceEvent("TilesActivity", OsmSharp.Logging.TraceEventType.Information, _mapView.CurrentView.ToString());
_mapView.Map.Close();
_mapView.Close();
_mapView.Dispose();
}
}
}
But none marker shows up.
No we actually ended using a web view and used java script with Bing.
Works well but there is no way to use it offline.
From: Yordan Yanakiev [mailto:[email protected]] Sent: Monday, March 7, 2016 6:51 AM To: OsmSharp/ui Cc: drewbolt Subject: Re: [ui] new MapMarker problem (#228)
Seems like I am experiencing the same issue. Did You found a solution ? My code so far is :
using System; using System.Collections.Generic; using System.Linq; using System.Text;
using Android.App; using Android.Content; using Android.OS; using Android.Runtime; using Android.Views; using Android.Widget; using OsmSharp.Android.UI; using OsmSharp.UI.Map; using OsmSharp.UI.Map.Layers; using OsmSharp.Math.Geo; using Android.Graphics; using OsmSharp.Android.UI.Controls;
namespace Android.Demo { [Activity(Label = "Online Tiles Demo")] public class TilesActivity : Activity { private MapView _mapView;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// hide title bar.
this.RequestWindowFeature(global::Android.Views.WindowFeatures.NoTitle);
// initialize map.
var map = new Map();
map.AddLayer( new LayerTile( "http://a.tile.openstreetmap.org/{0}/{1}/{2}.png <http://a.tile.openstreetmap.org/%7b0%7d/%7b1%7d/%7b2%7d.png> ", 160 ) );
// define the mapview.
var mapViewSurface = new MapViewSurface(this);
mapViewSurface.MapScaleFactor = 2;
_mapView = new MapView(this, mapViewSurface);
_mapView.Map = map;
_mapView.MapMaxZoomLevel = 18; // limit min/max zoom because MBTiles sample only contains a small portion of a map.
_mapView.MapMinZoomLevel = 0;
_mapView.MapTilt = 0;
_mapView.MapCenter = new GeoCoordinate( 43, 24 );
_mapView.MapZoom = 12;
_mapView.MapAllowTilt = false;
// set the map view as the default content view.
SetContentView(_mapView);
Bitmap bitmap = BitmapFactory.DecodeResource( this.Resources, Resource.Drawable.Icon );
var marker = new MapMarker( this, new GeoCoordinate( 43, 24 ) );//, MapControlAlignmentType.CenterBottom, bitmap );
_mapView.AddMarker( marker );
}
protected override void OnDestroy()
{
base.OnDestroy();
OsmSharp.Logging.Log.TraceEvent("TilesActivity", OsmSharp.Logging.TraceEventType.Information, _mapView.CurrentView.ToString());
_mapView.Map.Close();
_mapView.Close();
_mapView.Dispose();
}
}
}
But none marker shows up.
— Reply to this email directly or view it on GitHub https://github.com/OsmSharp/ui/issues/228#issuecomment-193219157 . https://github.com/notifications/beacon/ALojFGFzirDuOf361JTNZ0VGBHkMUL-nks5prBEmgaJpZM4D7yD1.gif
This message has been scanned by MailScanner.
This message has been scanned by MailScanner.
:( Do You know if this issue have been fixed at all ?
What version on android are u building in??
From: Yordan Yanakiev [mailto:[email protected]] Sent: Monday, March 7, 2016 9:16 AM To: OsmSharp/ui Cc: drewbolt Subject: Re: [ui] new MapMarker problem (#228)
:(
— Reply to this email directly or view it on GitHub https://github.com/OsmSharp/ui/issues/228#issuecomment-193264444 . https://github.com/notifications/beacon/ALojFCRXYmNAYumaTW-9fb1YM59c2rpWks5prDM0gaJpZM4D7yD1.gif
This message has been scanned by MailScanner.
This message has been scanned by MailScanner.
Compiler : API level 23 ( Android 6 ) just tried with level 10 ( 2.3 ), level 19 ( 4.4 ), level 21 ( 5.0 ), and level 22 ( 5.1 ) - same result - no marker at all.
Hum I did get it work with that API level. What Build action property do you have the Image set to?? I think it has to be set to android resource but I cant remember 100%. Also are you sure you are using a Valid geocoord?? Just make sure. A easy way to get one is by going to http://www.gps-coordinates.net/ just to make sure your looking in the correct place for the marker on you app.
From: Yordan Yanakiev [mailto:[email protected]] Sent: Monday, March 7, 2016 9:38 AM To: OsmSharp/ui Cc: drewbolt Subject: Re: [ui] new MapMarker problem (#228)
Compiler : API level 23.
— Reply to this email directly or view it on GitHub https://github.com/OsmSharp/ui/issues/228#issuecomment-193274575 . https://github.com/notifications/beacon/ALojFKXIWBloa24xGnooYpaCLex5gRsiks5prDhQgaJpZM4D7yD1.gif
This message has been scanned by MailScanner.
This message has been scanned by MailScanner.
Also something to consider it might make things easier if you get the marker to draw on a button press or some other event.
I know if shouldn’t matter in theory but I have found that the android lifecycle sometimes causes some issues with drawing images in the mapview. I was using onlocation changed from the GPS when I got mine to work..
From: Yordan Yanakiev [mailto:[email protected]] Sent: Monday, March 7, 2016 9:38 AM To: OsmSharp/ui Cc: drewbolt Subject: Re: [ui] new MapMarker problem (#228)
Compiler : API level 23.
— Reply to this email directly or view it on GitHub https://github.com/OsmSharp/ui/issues/228#issuecomment-193274575 . https://github.com/notifications/beacon/ALojFKXIWBloa24xGnooYpaCLex5gRsiks5prDhQgaJpZM4D7yD1.gif
This message has been scanned by MailScanner.
This message has been scanned by MailScanner.
The image is ok - seted as AndroidResource, the coordinates are valid, it is place near me.
var aButton = new Button( this );
aButton.Text = "add marker";
aButton.Click += ( sender, e ) =>
{
Bitmap bitmap = BitmapFactory.DecodeResource( this.Resources, Resource.Drawable.Icon );
var marker = new MapMarker( this, new GeoCoordinate( 43, 24 ) );//, MapControlAlignmentType.CenterBottom, bitmap );
_mapView.AddMarker( marker );
};
layout.AddView( aButton );
layout.AddView( _mapView );
SetContentView( layout );
Nope. even on user raised event - nothing happens yet - no marker..