本文整理汇总了C#中Android.Gms.Maps.Model.MarkerOptions.InvokeIcon方法的典型用法代码示例。如果您正苦于以下问题:C# MarkerOptions.InvokeIcon方法的具体用法?C# MarkerOptions.InvokeIcon怎么用?C# MarkerOptions.InvokeIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Gms.Maps.Model.MarkerOptions
的用法示例。
在下文中一共展示了MarkerOptions.InvokeIcon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnElementPropertyChanged
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged (sender, e);
var androidMapView = (MapView)Control;
var formsMap = (CustomMap)sender;
if (e.PropertyName.Equals ("VisibleRegion") && !_isDrawnDone) {
androidMapView.Map.Clear ();
androidMapView.Map.MarkerClick += HandleMarkerClick;
androidMapView.Map.MyLocationEnabled = formsMap.IsShowingUser;
var formsPins = formsMap.CustomPins;
foreach (var formsPin in formsPins) {
var markerWithIcon = new MarkerOptions ();
markerWithIcon.SetPosition (new LatLng (formsPin.Position.Latitude, formsPin.Position.Longitude));
markerWithIcon.SetTitle (formsPin.Label);
markerWithIcon.SetSnippet (formsPin.Address);
if (!string.IsNullOrEmpty (formsPin.PinIcon))
markerWithIcon.InvokeIcon (BitmapDescriptorFactory.FromAsset (String.Format ("{0}.png", formsPin.PinIcon)));
else
markerWithIcon.InvokeIcon (BitmapDescriptorFactory.DefaultMarker ());
androidMapView.Map.AddMarker (markerWithIcon);
}
_isDrawnDone = true;
}
}
示例2: UpdatePins
private void UpdatePins()
{
var androidMapView = (MapView)Control;
var formsMap = (ExtendedMap)Element;
androidMapView.Map.Clear ();
androidMapView.Map.MarkerClick += HandleMarkerClick;
androidMapView.Map.MyLocationEnabled = formsMap.IsShowingUser;
var items = formsMap.Items;
foreach (var item in items) {
var markerWithIcon = new MarkerOptions ();
markerWithIcon.SetPosition (new LatLng (item.Location.Latitude, item.Location.Longitude));
markerWithIcon.SetTitle (string.IsNullOrWhiteSpace(item.Name) ? "-" : item.Name);
markerWithIcon.SetSnippet (item.Details);
try
{
markerWithIcon.InvokeIcon(BitmapDescriptorFactory.FromResource(GetPinIcon()));
}
catch (Exception)
{
markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker());
}
androidMapView.Map.AddMarker (markerWithIcon);
}
}
示例3: updateEpins
private void updateEpins()
{
var androidMapView = (MapView)Control;
var formsMap = (Xam.Plugin.MapExtend.Abstractions.MapExtend)Element;
androidMapView.Map.Clear();
androidMapView.Map.MarkerClick += HandleMarkerClick;
androidMapView.Map.MyLocationEnabled = formsMap.IsShowingUser;
var items = formsMap.EPins;
foreach (var item in items)
{
var markerWithIcon = new MarkerOptions();
markerWithIcon.SetPosition(new LatLng(item.Location.Latitude, item.Location.Longitude));
markerWithIcon.SetTitle(string.IsNullOrWhiteSpace(item.Name) ? "-" : item.Name);
markerWithIcon.SetSnippet(item.Details);
try
{
markerWithIcon.InvokeIcon(BitmapDescriptorFactory.FromResource(Resources.GetIdentifier(item.ResourceNameImg, "drawable", Context.PackageName)));
}
catch (Exception)
{
markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker());
}
androidMapView.Map.AddMarker(markerWithIcon);
}
}
示例4: AddPin
private void AddPin(ExtendedPin formsPin)
{
var androidMapView = (MapView) Control;
var markerWithIcon = new MarkerOptions();
markerWithIcon.SetPosition(new LatLng(formsPin.Position.Latitude, formsPin.Position.Longitude));
markerWithIcon.SetTitle(formsPin.Label);
markerWithIcon.SetSnippet(formsPin.Address);
if (!string.IsNullOrEmpty(formsPin.PinIcon))
{
markerWithIcon.InvokeIcon(BitmapDescriptorFactory.FromResource(GetResourceIdByName(formsPin.PinIcon)));
}
else
markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker());
androidMapView.Map.AddMarker(markerWithIcon);
}
示例5: SetupMapIfNeeded
private void SetupMapIfNeeded()
{
if (_map == null)
{
_map = _mapFragment.Map;
if (_map != null)
{
MarkerOptions markerOpt1 = new MarkerOptions();
markerOpt1.SetPosition(VimyRidge);
markerOpt1.SetTitle("Vimy Ridge");
markerOpt1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueCyan));
_map.AddMarker(markerOpt1);
MarkerOptions markerOpt2 = new MarkerOptions();
markerOpt2.SetPosition(Passchendaele);
markerOpt2.SetTitle("Passchendaele");
_map.AddMarker(markerOpt2);
// We create an instance of CameraUpdate, and move the map to it.
CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngZoom(VimyRidge, 15);
_map.MoveCamera(cameraUpdate);
}
}
}
示例6: DrawMap
async public void DrawMap()
{
if ( _stateClass._person != null)
{
_mapFragment = MapFragment.FragmentManager.FindFragmentById(Resource.Id.map) as MapFragment;
_map = _mapFragment.Map;
_map.Clear();
// Set the map type
// show user location
_map.MyLocationEnabled = true;
// setup a location manager
_locationManager = _mainActivity.GetSystemService (Context.LocationService) as LocationManager;
// use a generic location provider instead
Criteria locationCriteria = new Criteria();
locationCriteria.Accuracy = Accuracy.Coarse;
locationCriteria.PowerRequirement = Power.Medium;
await System.Threading.Tasks.Task.Delay(0);
var geoCoder = new Geocoder(_mainActivity);
try
{
Address address = this.GetAddressesFromLocation(_stateClass._person.Strasse,_stateClass._person.PLZ,_stateClass._person.Ort,_stateClass._person.Land);
MarkerOptions marker1 = new MarkerOptions();
if (address != null)
{
marker1.SetPosition(new LatLng(address.Latitude, address.Longitude));
marker1.SetTitle(_stateClass._person.Name + " - " + _stateClass._person.Strasse + " - " + _stateClass._person.Ort + "- " + _stateClass._person.Umsatz);
marker1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed));
_Marker = _map.AddMarker(marker1);
_map.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(new Android.Gms.Maps.Model.LatLng(address.Latitude, address.Longitude), 9.0f));
}
else
{
Android.Widget.Toast.MakeText(_mainActivity,_mainActivity.Resources.GetString(Resource.String.AddresseNichtGefunden), Android.Widget.ToastLength.Short).Show();
}
_map.MarkerClick += (object sender, GoogleMap.MarkerClickEventArgs markerClickEventArgs) =>
{
markerClickEventArgs.Handled = true;
Marker marker = markerClickEventArgs.Marker;
_map.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(marker.Position, 13));
marker.ShowInfoWindow();
};
}
catch(Exception ex)
{
DataAccessLayer.ExceptionWriter.WriteLogFile(ex);
}
}
}
示例7: AddDeviceMarkerToMap
private Marker AddDeviceMarkerToMap(Device dev)
{
var loc = new LatLng (dev.LastLocation.Lat, dev.LastLocation.Lng);
MarkerOptions marker = new MarkerOptions ();
marker.InvokeIcon (BitmapDescriptorFactory.DefaultMarker (BitmapDescriptorFactory.HueGreen));
marker.SetPosition (loc);
String location;
location = GetAddress (loc.Latitude, loc.Longitude);
if (location == null)
location = loc.Latitude.ToString() + ", " + loc.Longitude.ToString();
marker.SetSnippet (location);
marker.SetTitle (dev.Name);
MyLogger.Information (this.LocalClassName, string.Format ("Device Marker Added: {0} at {1}", dev.Name, loc.ToString ()));
return AddMarkerToMap (marker);
}
示例8: AddNewMarkerToMap
private Marker AddNewMarkerToMap(MapFragment mapFragment, LatLng position, BitmapDescriptor icon)
{
var marker = new MarkerOptions();
marker.SetPosition(position);
marker.InvokeIcon(icon);
var actualMarker = mapFragment.Map.AddMarker(marker);
return actualMarker;
}
示例9: UpdateMap
void UpdateMap( bool result )
{
// sanity checks in case loading the map fails (Google Play can error)
if ( Map != null )
{
Map.Clear( );
MarkerList.Clear( );
string address = SearchPage.Street.Text + " " + SearchPage.City.Text + ", " + SearchPage.State.Text + ", " + SearchPage.ZipCode.Text;
if ( GroupEntries.Count > 0 )
{
Android.Gms.Maps.Model.LatLngBounds.Builder builder = new Android.Gms.Maps.Model.LatLngBounds.Builder();
// add the source position
Android.Gms.Maps.Model.MarkerOptions markerOptions = new Android.Gms.Maps.Model.MarkerOptions();
Android.Gms.Maps.Model.LatLng pos = new Android.Gms.Maps.Model.LatLng( SourceLocation.Latitude, SourceLocation.Longitude );
markerOptions.SetPosition( pos );
markerOptions.InvokeIcon( BitmapDescriptorFactory.DefaultMarker( BitmapDescriptorFactory.HueGreen ) );
builder.Include( pos );
Android.Gms.Maps.Model.Marker marker = Map.AddMarker( markerOptions );
MarkerList.Add( marker );
for ( int i = 0; i < GroupEntries.Count; i++ )
{
// add the positions to the map
markerOptions = new Android.Gms.Maps.Model.MarkerOptions();
pos = new Android.Gms.Maps.Model.LatLng( GroupEntries[ i ].Latitude, GroupEntries[ i ].Longitude );
markerOptions.SetPosition( pos );
markerOptions.SetTitle( GroupEntries[ i ].Title );
markerOptions.SetSnippet( string.Format( "{0:##.0} {1}", GroupEntries[ i ].Distance, ConnectStrings.GroupFinder_MilesSuffix ) );
builder.Include( pos );
marker = Map.AddMarker( markerOptions );
MarkerList.Add( marker );
}
Android.Gms.Maps.Model.LatLngBounds bounds = builder.Build( );
int paddingInPixels = Math.Min( View.Width, (int)(View.Height * .1f) );
CameraUpdate camPos = CameraUpdateFactory.NewLatLngBounds( bounds, paddingInPixels );
Map.AnimateCamera( camPos );
// show the info window for the first (closest) group
MarkerList[ 1 ].ShowInfoWindow( );
SearchResultPrefix.Text = ConnectStrings.GroupFinder_Neighborhood;
SearchResultNeighborhood.Text = GroupEntries[ 0 ].NeighborhoodArea;
// record an analytic that they searched
GroupFinderAnalytic.Instance.Trigger( GroupFinderAnalytic.Location, address );
GroupFinderAnalytic.Instance.Trigger( GroupFinderAnalytic.Neighborhood, GroupEntries[ 0 ].NeighborhoodArea );
( ListView.Adapter as GroupArrayAdapter ).SetSelectedRow( 0 );
}
else
{
if ( result == true )
{
SearchResultPrefix.Text = ConnectStrings.GroupFinder_NoGroupsFound;
SearchResultNeighborhood.Text = string.Empty;
// no groups found, so move the camera to the default position
Android.Gms.Maps.Model.LatLng defaultPos = new Android.Gms.Maps.Model.LatLng( ConnectConfig.GroupFinder_DefaultLatitude, ConnectConfig.GroupFinder_DefaultLongitude );
CameraUpdate camPos = CameraUpdateFactory.NewLatLngZoom( defaultPos, ConnectConfig.GroupFinder_DefaultScale_Android );
Map.AnimateCamera( camPos );
// record that this address failed
GroupFinderAnalytic.Instance.Trigger( GroupFinderAnalytic.OutOfBounds, address );
( ListView.Adapter as GroupArrayAdapter ).SetSelectedRow( -1 );
}
else
{
// there was actually an error. Let them know.
SearchResultPrefix.Text = ConnectStrings.GroupFinder_NetworkError;
SearchResultNeighborhood.Text = string.Empty;
}
}
}
}
示例10: OnStart
public override void OnStart ()
{
base.OnStart ();
if (_person != null)
{
_mapFragment = FragmentManager.FindFragmentById(Resource.Id.map) as MapFragment;
if (_mapFragment == null)
return;
_map = _mapFragment.Map;
// Set the map type
_map.MapType = GoogleMap.MapTypeNormal;
// show user location
_map.MyLocationEnabled = true;
// setup a location manager
_locationManager = _activity.GetSystemService (Context.LocationService) as LocationManager;
// use a generic location provider instead
Criteria locationCriteria = new Criteria();
locationCriteria.Accuracy = Accuracy.Coarse;
locationCriteria.PowerRequirement = Power.Medium;
var geoCoder = new Geocoder(_activity);
try
{
Address address = this.GetAddressesFromLocation(_person.Strasse,_person.PLZ,_person.Ort,_person.Land);
MarkerOptions marker1 = new MarkerOptions();
if (address != null)
{
marker1.SetPosition(new LatLng(address.Latitude, address.Longitude));
marker1.SetTitle(_person.Name + " - " + _person.Strasse + " - " + _person.Ort + "- " + _person.Umsatz);
marker1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed));
_Marker = _map.AddMarker(marker1);
_map.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(new Android.Gms.Maps.Model.LatLng(address.Latitude, address.Longitude), 9.0f));
}
else
{
Android.Widget.Toast.MakeText(_activity,_activity.Resources.GetString(Resource.String.AddresseNichtGefunden), Android.Widget.ToastLength.Short).Show();
}
_map.MarkerClick += MapOnMarkerClick;
}
catch(Exception ex)
{
DataAccessLayer.ExceptionWriter.WriteLogFile(ex);
}
}
}
示例11: FindNearestPlace
async Task FindNearestPlace()
{
var geoCoder = new Geocoder(this);
var locations = await geoCoder.GetFromLocationAsync(Location_NewYork.Latitude, Location_NewYork.Longitude, 2);
if (locations.Count > 0)
{
foreach (var location in locations)
{
MarkerOptions marker1 = new MarkerOptions();
marker1.SetPosition(new LatLng(location.Latitude, location.Longitude));
marker1.SetTitle(location.FeatureName);
marker1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueYellow));
_map.AddMarker(marker1);
}
}
}
示例12: UpdatePins
private void UpdatePins()
{
var androidMapView = (MapView)Control;
var formsMap = (ExtendedMap)Element;
androidMapView.Map.Clear ();
androidMapView.Map.MarkerClick += HandleMarkerClick;
androidMapView.Map.MyLocationEnabled = formsMap.IsShowingUser;
if (formsMap.ItemsSource != null)
{
if (this.markers == null)
this.markers = new List<Marker> ();
var items = formsMap.ItemsSource.Cast<IMapModel> ();
foreach (var item in items)
{
var markerWithIcon = new MarkerOptions ();
markerWithIcon.SetPosition (new LatLng (item.Location.Latitude, item.Location.Longitude));
markerWithIcon.SetTitle (string.IsNullOrWhiteSpace (item.Name) ? "-" : item.Name);
markerWithIcon.SetSnippet (item.Details);
markerWithIcon.InvokeIcon (BitmapDescriptorFactory.DefaultMarker ());
var addedMarker = androidMapView.Map.AddMarker (markerWithIcon);
this.markers.Add (addedMarker);
}
}
}
示例13: UpdatePins
private void UpdatePins()
{
try
{
var mapTile = (MapTile)Element;
NativeMap.Clear();
foreach (var item in mapTile.PinList)
{
var markerWithIcon = new MarkerOptions();
markerWithIcon.SetPosition(new LatLng(item.Latitude, item.Longitude));
markerWithIcon.SetTitle("");
markerWithIcon.SetSnippet(item.Id);
try
{
if (CategoryHelper.CategoryList.ContainsKey(item.PrimaryCategory.TypeCode))
{
var categoryParam = CategoryHelper.CategoryList[item.PrimaryCategory.TypeCode];
var constIcon = 0;
if (categoryParam.Icon == CategoryHelper.ic_pin_coffee)
constIcon = Resource.Drawable.ic_pin_coffee;
else if (categoryParam.Icon == CategoryHelper.ic_pin_cinema)
constIcon = Resource.Drawable.ic_pin_cinema;
else if (categoryParam.Icon == CategoryHelper.ic_pin_photo)
constIcon = Resource.Drawable.ic_pin_photo;
else if (categoryParam.Icon == CategoryHelper.ic_pin_clothing)
constIcon = Resource.Drawable.ic_pin_clothing;
else if (categoryParam.Icon == CategoryHelper.ic_pin_entertainment)
constIcon = Resource.Drawable.ic_pin_entertainment;
else if (categoryParam.Icon == CategoryHelper.ic_pin_sport)
constIcon = Resource.Drawable.ic_pin_sport;
else if (categoryParam.Icon == CategoryHelper.ic_pin_food)
constIcon = Resource.Drawable.ic_pin_food;
if (constIcon != 0)
markerWithIcon.InvokeIcon(BitmapDescriptorFactory.FromResource(constIcon));
}
}
catch (Exception)
{
markerWithIcon.InvokeIcon(BitmapDescriptorFactory.DefaultMarker());
}
NativeMap.AddMarker(markerWithIcon);
}
if (AppMobileService.Locaion.IsAvailable())
{
var locationMarker = new MarkerOptions();
locationMarker.SetPosition(new LatLng(AppMobileService.Locaion.CurrentLocation.Latitude, AppMobileService.Locaion.CurrentLocation.Longitude));
locationMarker.SetTitle("");
locationMarker.SetSnippet(CurrentLocationSnippet);
try
{
locationMarker.InvokeIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.ic_pin_navigation));
}
catch (Exception)
{
locationMarker.InvokeIcon(BitmapDescriptorFactory.DefaultMarker());
}
NativeMap.AddMarker(locationMarker);
}
}
catch (Exception ex)
{
}
}
示例14: UpdatePins
private void UpdatePins()
{
var androidMapView = (MapView)Control;
var formsMap = (ExtendedMap)Element;
androidMapView.Map.Clear ();
androidMapView.Map.MyLocationEnabled = formsMap.IsShowingUser;
if (formsMap.ItemsSource != null) {
if (this.markers == null)
this.markers = new List<Marker> ();
var items = formsMap.ItemsSource.Cast<IMapModel> ();
foreach (var item in items) {
var markerWithIcon = new MarkerOptions ();
markerWithIcon.SetPosition (new LatLng (item.Location.Latitude, item.Location.Longitude));
markerWithIcon.SetTitle (string.IsNullOrWhiteSpace (item.Name) ? "-" : item.Name);
markerWithIcon.SetSnippet (item.Details);
markerWithIcon.InvokeIcon (BitmapDescriptorFactory.DefaultMarker ());
var addedMarker = androidMapView.Map.AddMarker (markerWithIcon);
this.markers.Add (addedMarker);
}
var central = GeoHelper.GetCentralPosition (items.Select (i => i.Location));
var radius = GeoHelper.GetRadius (central, items.Select (i => i.Location), true);
this.MoveToRegion (
MapSpan.FromCenterAndRadius (
central,
Distance.FromMeters (radius)
),
false
);
}
}
示例15: createMarker
//create market: if my=true => load image mylocation
private MarkerOptions createMarker(LatLng latLng, string title, string subTitle, bool my)
{
MarkerOptions option = new MarkerOptions ();
option.SetPosition (latLng);
option.SetTitle (title);
option.SetSnippet (subTitle);
if (my)
option.InvokeIcon (BitmapDescriptorFactory.FromResource (Resource.Drawable.my_location));
return option;
}