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

Make NavigationBar do not render at all or display page only when completly loaded
How to create a code-only webview with Xamarin.Forms
Test in cloud button has gone
MvvmCross MvxSpinner does not update after re-entering
Unable to deploy to iOS device: Failed to resolve “System.Configuration.ConfigurationException”
Custom font not displaying on Android with Xamarin Forms and Prism
Is it required to have a Xamarin account in order to build Xamarin projects in VS 2017
How to use auto scroll in Xamarin forms
How to create constraint in Xamarin iOS
Xamarin with Visual Studio 2015 can't start new project
Simple.OData.Client: expand related entities
How to pass the OTP read in broadcast receiver from xamarin droid to PCL?
Xamarin iOS Activity Indicator with Another image
Why doesn't navigationbar change colour in Xamarin.Forms on some devices?
Xamarin Refit - Could not load assembly error
Xamarin [RestSharp] + [Xam.Plugin.Media] upload model containing image

Categories

HOME
arduino-uno
vim
wso2
vbscript
amazon-ec2
path-finding
office365api
relay
rsyslog
filtering
ckeditor
baqend
add
cloudkit
windows-10-universal
here-api
rascal
windows-azure-storage
visual-studio-2005
designer
openrefine
windows-7-x64
apache-metamodel
alpine
zapier
facebook-instant-articles
google-search-api
microsoft-r
icloud-api
one-to-many
numerical-methods
chromebook
nhapi
tooltipster
filezilla
iframe-resizer
galsim
contact-form
language-concepts
http-referer
html5-fullscreen
bytecode-manipulation
jquery-bootgrid
space-complexity
gesture
ssjs
ansible-playbook
splice
squib
broadcastreceiver
http-redirect
import-from-excel
appcompat
pubmed
jlink
alphabet
mplayer
gcsfuse
nested-sets
parallel-data-warehouse
medium.com
database-optimization
ctest
angstrom-linux
whois
bluegiga
asp.net5
wso2cloud
collapse
content-length
iis-arr
vstest.console.exe
angular-local-storage
dd
qpainter
internet-connection
rdl
starcluster
rebol3
apc
cos
buster.js
back-stack
gridcontrol
rdoc
bluepill
broken-links
armcc
enter
semantic-diff
mercurial-server
infobox
site.master
suppress
xsdobjectgen
forums
user-friendly
multi-tier
memory-size
procedural-music
mediarss
data-acquisition

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