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

How to resume the application and open a specific page with a push notification in Xamarin.forms
Xamarin Forms Force view to bind values
MTOUCH: error MT0010: Could not parse the command line arguments:
How to modify a constraint using mvvmcross fluentLayout
SignaturePad Xamarin Forms PCL unable to capture Image
How to make parent stretch the given space that a child needs?
Xamarin Studio can't open solution after update
no Xamarin portable class library
Error Running Local Test on Real Device using Xamarin UITest and Visual Studio 2015
“aapt.exe” exited with code 1. in VS 2015
Xamarin - How to add endpoints automatically to Amazon SNS
Xamarin Forms Xamarin Android
UnRegister viewmodels MVVLight at logout
Xamarin Forms: IMarkupExtension with bindable property does not work
ScrollToAsync in scrollview
'Could not add Microsoft.ProjectOxford.Face' Why can't I add this nuget to my Xamarin.Forms.iOS project?

Categories

HOME
twitter
openlayers
cookies
omnet++
openstack
ngrx
dictionary
mfc
dot
jsrender
blueprintjs
windows-server
serverspec
session-variables
tomcat6
hex-editors
caml
dosgi
firefox-webextensions
textfield
riot.js
orleans
sox
angular2-aot
h2db
chromebook
social-media
strncpy
elasticsearch-ruby
unboundid
directx-10
javascriptcore
pdb
grails-3.1
wpf-controls
ios5
adobe-premiere
event-driven
optix
g-code
core-plot
elmah
http-live-streaming
android-mediaprojection
filepicker
errordocument
worksheet
jlink
rdfs
yii2-extension
nodebb
mako
bind9
sonarlint-vs
probability-density
url-masking
storekit
gridview-sorting
disque
hill-climbing
uid
reactive-banana
qtableview
fouc
ideamart
dundas
pretty-print
c3
tablelayout
network-interface
gulp-less
ceil
article
yorick
seaside
stxxl
flash-builder4.5
jplaton
eventual-consistency
comaddin
jelly
e4x
manchester-syntax
ohm
subscript
hirefire
gcj
tomcat-valve
f#-powerpack
lang
paster
firefox4
brewmp
adrotator
eqatec
zend-decorators
document-conversion

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