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

System.Collections.Generic.KeyNotFoundException
IPA and APK size develop in Xamarin and native
Xamarin iOS Visual Studio - Can't select Show Detail Segue
Open Pdf File in Xamarin.forms
Topaz Signature Pad throws Exception: NetworkError when I launch it from JS code inside WebView in Xamarin UWP Windows App
App.Current.Properties in Service after ActionBootCompleted
Xamarin circular activity indicator for UWP
Xamarin.Forms Hockey App Error CrashManager.Register
How to navigate deeper inside a xamarin detailpage
Xamarin WebView scale to fit
Row is not resizing on ios with xamarin forms
How to get current location in Xamarin.Forms.Maps?
How to calulate coordinates of the phone on Xamarin Android?
UWP UART send/recieve bytes incorrectly
Azure Storage SDK method PushFileChangesAsync fails to create hash
Edit reference shows empty in Xamarin Studio

Categories

HOME
ms-access
variables
omnet++
mediawiki
ngrx
dxl
fsm
baqend
podio
upload
ssl-client-authentication
wheelnav.js
handsontable
n-gram
size
static-libraries
dtrace
serverless-framework
telephony
angular-ui
google-cloud-speech
immutable.js
one-hot-encoding
clickonce
arabic
facebook-instant-articles
wijmo
rundeck
virtualdub
tooltipster
web-api-testing
assistant
jspm
uisplitview
usbserial
framemaker
stringtemplate
form-data
hexo
revolution-slider
restlet
dartium
lto
withings
jna
mesos-chronos
ws-security
optix
wso2carbon
filepicker
jlink
jxcore
libusb-win32
google-perftools
memory-alignment
linode
mcafee
instant
log4c
py2app
mongocsharpdriver
multiple-regression
connect-by
nsviewcontroller
persist
hover-over
tcpserver
ibaction
processmodel
notify
lustre
kineticjs
codeigniter-routing
qcodo
bitcoinj
flask-cors
castle
typeof
contenttype
mbr
fmod
page-layout
tidy
back-stack
qt-faststart
django-nonrel
wsdl-2.0
e4x
labwindows
wse3.0
nsmanagedobject
semantic-diff
transactionscope
gwt-ext
coercion
horizontal-accordion
yetanotherforum
imac
yslow
vc90
firefox4
nintendo-ds
ugc

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