xamarin


How to take longitute and latitude in different locations using marker in maps xamarin.android


i am able to get my current location using marker but unable to set the marker into different locations and get the latitude and longitude values using marker.
public class googlemapsAc : Activity, ILocationListener, IOnMapReadyCallback
{
GoogleMap _map;
LocationManager locManager;
TextView loc1, loc2;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.mapsActivity);
loc1 = FindViewById<TextView>(Resource.Id.btn_loc);
loc1 = FindViewById<TextView>(Resource.Id.btn_loc2);
locManager = (LocationManager)GetSystemService(LocationService);
locManager.RequestLocationUpdates(LocationManager.GpsProvider, 0,0, this);
Location location = locManager.GetLastKnownLocation(LocationManager.GpsProvider);
MapFragment mapFrag = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map);
mapFrag.GetMapAsync(this);
if (location != null)
{
MarkerOptions options = new MarkerOptions();
LatLng lat = new LatLng(location.Latitude, location.Longitude);
Toast.MakeText(this,"Current location:\nLatitude: " + location.Latitude+ "\n" + "Longitude: " + location.Longitude,ToastLength.Long).Show();
options.SetPosition(lat);
p.AddMarker(options);
}
else
{
Toast.MakeText(this, "Cannot fetch current location!",ToastLength.Short).Show();
}
locManager.RemoveUpdates(this);
}
public void OnLocationChanged(Location location)
{
}
public void OnProviderDisabled(string provider)
{
throw new NotImplementedException();
}
public void OnProviderEnabled(string provider)
{
throw new NotImplementedException();
}
public void OnStatusChanged(string provider, [GeneratedEnum] Availability status, Bundle extras)
{
throw new NotImplementedException();
}
protected override void OnResume()
{
base.OnResume();
locManager.RequestLocationUpdates(LocationManager.GpsProvider, 0,0, this);
}
protected override void OnPause()
{
base.OnPause();
locManager.RemoveUpdates(this);
}
public void OnMapReady(GoogleMap googleMap)
{
_map = googleMap;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="#+id/btn_loc" />
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="#+id/btn_loc2" />
<fragment
android:id="#+id/map"
android:layout_height="match_parent"
android:layout_width="match_parent"
class="com.google.android.gms.maps.MapFragment" />
</LinearLayout>
in this code i am able get the current location in toast message,but when i change the location of marker i didn't get the latitude and longitude values into marker to bind that values to text view.
please help me with getting lat lang values using place markers to bind to Textview
in this code i am able get the current location in toast message,but when i change the location of marker i didn't get the latitude and longitude values into marker to bind that values to text view.
I didn't see any code about how you change the location of marker, but you can get the latitude and longitude directly from your marker for example like this:
var latitude = marker.Position.Latitude;
var longitude = marker.Position.Longitude;

Related Links

Enabling Barcode using Zxing ( Zebra Xing) on Xamarin iOS [duplicate]
How to use async method in DelegateCommand
Android: Add Custom keyboard to Xamarin.Forms
How to get/set current volume level in Xamarin froms?
Xamarin - apk App Size
How to add XML documentation comments to Xamarin iOS Bindings Library?
Canceling BluetoothSocket InputStream read
Show nearby premises based on current location from a list of premises
Connection between View & ViewModel MVVM Light
Xamarin Forms - retrieve value of dynamically added entry control value on button click
Xamarin forms notification registration is not working
xamarin.social missing and cannot be installed
Xamarin Forms listview out of memory error
XamarinEvolve.Backend database required for running backend service
PCL library support for Log capture in release model in Xamarin
Subscribing to Prism Eventaggregator in view?

Categories

HOME
ibm-bluemix
hook
blogger
kde
cvs
filtering
cmd
leon
retrofit
fingerprint
wamp
qore
autotools
add
python-unittest
spring-kafka
static-libraries
orchardcms
quickfix
hapi
caml
serilog
database-replication
evopdf
ab-testing
contextmenu
shared-hosting
visual-composer
clickonce
extjs5
kudan
smb
wpfdatagrid
filezilla
minitab
assistant
sql-server-2012-express
frame
ecto
galsim
catel
usbserial
commit
main
dosbox
vapor
webix-treetable
sql-server-agent
glew
fakeiteasy
netcdf4
sas-jmp
celery-task
slickedit
dtexec
memory-alignment
linode
parallel-data-warehouse
url-pattern
passport-google-oauth
rotativa
url-masking
login-control
google-web-starter-kit
firebaseui
pagedlist
packagist
bgp
hexdump
two-factor-authentication
cloudbees
lib.web.mvc
tarjans-algorithm
microbenchmark
c++03
gwidgets
gui-test-framework
markers
castle
page-layout
jmapviewer
cos
buster.js
qt-faststart
android-hardware
angularjs-controller
venn-diagram
datawindow
objective-c-2.0
hgsubversion
hamachi
locationlistener
lang
lpeg
paster
filtered-index
nhibernate.search
asp.net-profiles
nintendo-ds
avatar
sector
3gp

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App