本文整理汇总了C#中Android.Gms.Maps.Model.MarkerOptions.SetTitle方法的典型用法代码示例。如果您正苦于以下问题:C# MarkerOptions.SetTitle方法的具体用法?C# MarkerOptions.SetTitle怎么用?C# MarkerOptions.SetTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Gms.Maps.Model.MarkerOptions
的用法示例。
在下文中一共展示了MarkerOptions.SetTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: setAdress
private async void setAdress(MarkerOptions pinMarker, GoogleMap.MapClickEventArgs e)
{
string adress = "";
// Obtengo la posible dirección a partir de la latitud y longitud
Geocoder geocoder = new Geocoder();
IEnumerable<string> possibleAdresses = await geocoder.GetAddressesForPositionAsync(new Position(e.Point.Latitude, e.Point.Longitude));
adress = possibleAdresses.ElementAt(0);
pinMarker.SetTitle(adress);
// Añado el pin al mapa
_map.AddMarker(pinMarker).ShowInfoWindow();
// Comparto el punto en App
var myApp = App.Current as App;
myApp.meetingPoint = new MeetingPoint
{
Name = adress,
Place = new Position(e.Point.Latitude, e.Point.Longitude)
};
}
示例2: MapRoute
public MapRoute(GoogleMap map, List<Station> stations)
{
_map = map;
_mapRoutes = new List<Polyline>();
_mapStations = new List<Marker>();
// Choose color;
Color color = Color.DodgerBlue;
// Create polyline.
var polyline = new PolylineOptions();
polyline.InvokeWidth(4f);
polyline.InvokeColor(color);
for (var i = 0; i < stations.Count; i++)
{
// Add points to polyline.
var station = stations[i];
if (station != null && station.latitude != 0f && station.longitude != 0f)
{
var latlng = new Android.Gms.Maps.Model.LatLng(station.latitude, station.longitude);
polyline.Add(latlng);
// Create marker.
var marker = new MarkerOptions();
marker.SetPosition(latlng);
marker.SetTitle((i + 1) + ". " + station.postName);
marker.Draggable(false);
marker.SetSnippet("ul. " + station.street);
_mapStations.Add(_map.AddMarker(marker));
}
}
// Add polyline to map.
_mapRoutes.Add(_map.AddPolyline(polyline));
}
示例3: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.FirstView);
var viewModel = (FirstViewModel) ViewModel;
var mapFragment = (SupportMapFragment)SupportFragmentManager.FindFragmentById(Resource.Id.map);
var options = new MarkerOptions();
options.SetPosition(new LatLng(viewModel.Keith.Location.Lat, viewModel.Keith.Location.Lng));
options.SetTitle("Keith");
_keith = mapFragment.Map.AddMarker(options);
var options2 = new MarkerOptions();
options2.SetPosition(new LatLng(viewModel.Helen.Location.Lat, viewModel.Helen.Location.Lng));
options2.SetTitle("Helen");
_helen = mapFragment.Map.AddMarker(options2);
var set = this.CreateBindingSet<FirstView, FirstViewModel>();
set.Bind(_keith)
.For(m => m.Position)
.To(vm => vm.Keith.Location)
.WithConversion(new LocationToLatLngValueConverter(), null);
set.Bind(_helen)
.For(m => m.Position)
.To(vm => vm.Helen.Location)
.WithConversion(new LocationToLatLngValueConverter(), null);
set.Apply();
}
示例4: 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;
}
}
示例5: adddatatomap
// Function to add data fields passed on from Main Activity (Latitude, Longitude, Address - then adds a tag to marker utilising the address field if there's any)
public void adddatatomap()
{
MarkerOptions opt = new MarkerOptions();
double lat = Convert.ToDouble(Intent.GetStringExtra("Latitude"));
double lng = Convert.ToDouble(Intent.GetStringExtra("Longitude"));
string address = Intent.GetStringExtra("Address");
LatLng location = new LatLng(lat, lng);
opt.SetPosition(location);
opt.SetTitle(address);
map.AddMarker(opt); // Adds a marker to map based on the address that was past on from our Main Activity
// Positioning the camera to show the marker based on fields parameter as set below
CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
builder.Target(location);
builder.Zoom(15);
builder.Bearing(90);
builder.Tilt(65);
CameraPosition cameraPosition = builder.Build();
CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition);
map.MoveCamera(cameraUpdate);
// Marker window clicked event
map.InfoWindowClick += map_InfoWindowClick;
// Marker dragged event
map.MarkerDragEnd += map_MarkerDragEnd;
}
示例6: 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);
}
}
示例7: 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);
}
}
示例8: MapRenderer2Android
public MapRenderer2Android()
: base()
{
WireUpMap();
MessagingCenter.Subscribe<IEnumerable<HeritageProperty>>(this, MapRenderer2.MESSAGE_ADD_AND_ZOOM_ON_PINS, async (items) =>
{
// wait for map
await WaitForMap();
// loop all the properties and add them as markers
foreach (var item in items)
{
// create the marker
var m = new MarkerOptions();
m.SetPosition(new LatLng(item.Latitude, item.Longitude));
m.SetTitle(item.Name);
// add to map
this.NativeMap.AddMarker(m);
}
// zoom in on the pins
ZoomAndCenterMap(items);
});
MessagingCenter.Subscribe<IEnumerable<HeritageProperty>>(this, MapRenderer2.MESSAGE_ZOOM_ON_PINS, (items) =>
{
// zoom in on the pins
ZoomAndCenterMap(items);
});
}
示例9: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.SecondView);
var viewModel = (SecondViewModel) ViewModel;
var mapFragment = (SupportMapFragment)SupportFragmentManager.FindFragmentById(Resource.Id.map);
var options = new MarkerOptions();
options.SetPosition(new LatLng(viewModel.Han.Location.Lat, viewModel.Han.Location.Lng));
options.SetTitle("Han");
options.Draggable(true);
var hanMarker = mapFragment.Map.AddMarker(options);
_han = new MarkerWrapper(hanMarker);
mapFragment.Map.MarkerDragEnd += (sender, args) =>
{
_han.FirePositionChangedFromMap();
};
var set = this.CreateBindingSet<SecondView, SecondViewModel>();
set.Bind(_han)
.For(m => m.Position)
.To(vm => vm.Han.Location)
.WithConversion(new LocationToLatLngValueConverter(), null);
set.Apply();
}
示例10: addEvent
private void addEvent(net.cloudapp.geteventinfo.Eventas event1)
{
MarkerOptions marker = new MarkerOptions();
marker.SetPosition(new LatLng(event1.latitude, event1.longitude));
marker.SetTitle(event1.eventname);
marker.SetSnippet(event1.description);
marker.SetIcon(BitmapDescriptorFactory.FromAsset("f.png"));
gMap.AddMarker(marker);
}
示例11: FindCar
public static List<MarkerOptions> FindCar()
{
List<MarkerOptions> markers = new List<MarkerOptions>();
locationsFile = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
locationsFile = Path.Combine(locationsFile, "locations.txt");
IEnumerable<string> lines;
if (File.Exists (locationsFile)) {
lines = File.ReadLines (locationsFile);
} else {
return new List<MarkerOptions> ();
}
List<LocationRecord> records = new List<LocationRecord>();
foreach (string line in lines ){
LocationRecord record = JsonConvert.DeserializeObject<LocationRecord> (line);
records.Add(record);
}
IEnumerable<string> speed = from record in records
select record.calculatedSpeed > speedLimit ? "fast": "slow";
string[] speeds = speed.ToArray();
int i = 0;
for(i=0; i<speeds.Count(); i++) {
if (i > 0)
{
if (speeds[i] != speeds[i - 1] && speeds[i] == "slow")
{
int fasts = CountFasts(speeds, i);
int slows = CountSlows(speeds, i);
long fastTime = records[i].unixTime - records[i-fasts].unixTime;
long slowTime = -( records[i].unixTime - records[i+slows].unixTime );
if (fastTime > millisBefore && slowTime > millisAfter && (DateTime.Now - records[i].time).TotalDays < 3)
{
MarkerOptions options = new MarkerOptions ();
options.SetPosition (new LatLng (records[i].latitude, records[i].longitude));
options.SetTitle (records[i].time.ToShortTimeString ());
options.SetSnippet (!double.IsNaN(records[i].recordedSpeed)?"Speed: " + String.Format ("{0:0.00}", records[i].recordedSpeed*3.6) + " km/h":"Speed: " + String.Format ("{0:0.00}", records[i].calculatedSpeed*3.6) + " km/h");
markers.Add(options);
}
}
}
}
return markers;
}
示例12: OnMapReady
public void OnMapReady (GoogleMap googleMap)
{
gMap = googleMap;
SetUpMapAllEvents ();
gMap.MapLongClick += (object sender, GoogleMap.MapLongClickEventArgs e) => {
MarkerOptions marker = new MarkerOptions();
marker.SetPosition(new LatLng(e.Point.Latitude, e.Point.Longitude));
marker.SetTitle("Kasis");
marker.SetIcon(BitmapDescriptorFactory.DefaultMarker (BitmapDescriptorFactory.HueCyan));
gMap.AddMarker(marker);
};
}
示例13: OnElementChanged
protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Xamarin.Forms.View> e)
{
base.OnElementChanged(e);
extendedMap = (ExtendedMap)Element;
mapView = Control as MapView;
map = mapView.Map;
map.MarkerClick+= HandleMarkerClick;
// Pin tıklanınca sağalta açılan menüyü engellemek için
map.UiSettings.MapToolbarEnabled = true;
map.UiSettings.MyLocationButtonEnabled = true;
if (extendedMap.isOverlayNeeded) {
LatLng southwest = new LatLng (extendedMap.sw.Latitude, extendedMap.sw.Longitude);
LatLng northeast = new LatLng (extendedMap.ne.Latitude, extendedMap.ne.Longitude);
LatLngBounds bounds = new LatLngBounds (southwest, northeast);
string url = extendedMap.overlayURL;//"http://www.mgm.gov.tr/mobile/mblhrt/data/radar/MAX--_6100_P00.png";
Bitmap objBitmap = GetImageBitmapFromUrl (url);
BitmapDescriptor objBitmapDescriptor = BitmapDescriptorFactory.FromBitmap (objBitmap);
GroundOverlayOptions objGroundOverlayOptions = new GroundOverlayOptions ().PositionFromBounds (bounds)/*.Position (objMapPosition, 100000)*/.InvokeImage (objBitmapDescriptor);
map.AddGroundOverlay (objGroundOverlayOptions);
//For freeing memory
objBitmap.Recycle ();
}
for (int i = 0; i < extendedMap.pinDatas.Count; i++) {
var markerWithIcon = new MarkerOptions ();
markerWithIcon.SetPosition (new LatLng (extendedMap.pinDatas[i].lat, extendedMap.pinDatas[i].lng));
markerWithIcon.SetTitle (i.ToString());
/*markerWithIcon.SetTitle ("aa");
markerWithIcon.SetSnippet ("bb");*/
int resID = Resources.GetIdentifier (extendedMap.pinDatas [i].icon, "drawable" , "com.app1001.bluemart");
//System.Diagnostics.Debug.WriteLine (resID);
markerWithIcon.SetIcon(BitmapDescriptorFactory.FromResource(resID));
map.AddMarker (markerWithIcon);
}
//Add Pins
//map.SetInfoWindowAdapter(this);
map.UiSettings.RotateGesturesEnabled = false;
}
示例14: googleMap_MapClick
private void googleMap_MapClick(object sender, GoogleMap.MapClickEventArgs e)
{
((MyBaseMap)Element).OnTap(new Position(e.Point.Latitude, e.Point.Longitude));
// Borramos el anterior Pin
_map.Clear();
var pinMarker = new MarkerOptions();
pinMarker.SetPosition(new LatLng(e.Point.Latitude, e.Point.Longitude));
pinMarker.SetTitle("Punto de encuentro :)");
pinMarker.DescribeContents();
setAdress(pinMarker, e);
// Añado el pin al mapa
_map.AddMarker(pinMarker).ShowInfoWindow();
}
示例15: adddatatomap
public void adddatatomap()
{
LatLng loc0=new LatLng(-37.773250,175.250250);
MarkerOptions opt0 = new MarkerOptions() //no semicolon
.SetPosition(loc0)
.SetRotation(45)
.SetAlpha(.5f)
.Draggable(true)
.SetTitle("In the waikato")
.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.Icon))
.SetSnippet("The presence of this actually creates an infowindow"); // which is why the other marker does not have one
map.AddMarker(opt0);
MarkerOptions opt1 = new MarkerOptions();
double lat = Convert.ToDouble(Intent.GetStringExtra("Latitude"));
double lng = Convert.ToDouble(Intent.GetStringExtra("Longitude"));
string address = Intent.GetStringExtra("Address");
LatLng location = new LatLng(lat, lng);
opt1.SetPosition(location);
opt1.SetTitle(address);
map.AddMarker(opt1);
// Positioning the camera to show the marker
CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
builder.Target(location);
builder.Zoom(15);
builder.Bearing(90);
builder.Tilt(65);
CameraPosition cameraPosition = builder.Build();
CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition);
map.MoveCamera(cameraUpdate);
//marker window clicked event
map.InfoWindowClick += map_InfoWindowClick;
//marker dragged event
map.MarkerDragEnd += map_MarkerDragEnd;
// map.SetInfoWindowAdapter(this);
// map.SetOnInfoWindowClickListener(this); //- implements the interface IOnInfoWindowclickListener
}