This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[BroadcastReceiver(Enabled = true)] | |
[IntentFilter(new[] { "com.huawei.hms.geofence.ACTION_PROCESS_ACTIVITY" })] | |
class GeofenceBroadcastReceiver : BroadcastReceiver | |
{ | |
public static readonly string ActionGeofence = "com.huawei.hms.geofence.ACTION_PROCESS_ACTIVITY"; | |
public override void OnReceive(Context context, Intent intent) | |
{ | |
if (intent != null) | |
{ | |
var action = intent.Action; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GeofenceManager | |
{ | |
public MainActivity activity; | |
public GeofenceManager(MainActivity activity) | |
{ | |
this.activity = activity; | |
} | |
private PendingIntent CreatePendingIntent() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async void btnInfoWindow_ClickAsync(object sender, System.EventArgs e) | |
{ | |
addressLayout = activity.LayoutInflater.Inflate(Resource.Layout.reverse_alert_layout, null); | |
//reverse geocode | |
GeocodeManager geocodeManager = new GeocodeManager(activity); | |
var addressResult = await geocodeManager.ReverseGeocode(selectedCoordinates.LatLng.Latitude, selectedCoordinates.LatLng.Longitude); | |
if (addressResult.ReturnCode != 0) | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"returnCode":"0", | |
"sites":[ | |
{ | |
"formatAddress":"Arapsuyu, 600. Sokak, 07070, Konyaaltı, Antalya, Türkiye", | |
"address":{ | |
"country":"Türkiye", | |
"countryCode":"TR", | |
"subLocality":"Arapsuyu", | |
"postalCode":"07070", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyLocation | |
{ | |
public double Lat { get; set; } | |
public double Lng { get; set; } | |
} | |
public class ReverseGeocodeRequest | |
{ | |
public MyLocation Location { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GeocodeManager | |
{ | |
public const string ApiKey = "YOUR_API_KEY” | |
private MainActivity activity; | |
public GeocodeManager(MainActivity activity) | |
{ | |
this.activity = activity; | |
} | |
public async Task<Site> ReverseGeocode(double lat, double lng) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void DrawCircleOnMap(GeofenceModel geoModel) | |
{ | |
if (circle != null) | |
{ | |
circle.Remove(); | |
circle = null; | |
} | |
CircleOptions circleOptions = new CircleOptions() | |
.InvokeCenter(geoModel.LatLng) | |
.InvokeRadius(geoModel.Radius) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class MapInfoWindowAdapter : Java.Lang.Object, HuaweiMap.IInfoWindowAdapter | |
{ | |
private MainActivity activity; | |
private GeofenceModel selectedCoordinates; | |
private View addressLayout; | |
public MapInfoWindowAdapter(MainActivity currentActivity) | |
{ | |
activity = currentActivity; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"> | |
<Button | |
android:text="Add geofence" | |
android:width="100dp" | |
style="@style/Widget.AppCompat.Button.Colored" | |
android:layout_width="wrap_content" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void HMap_MapClick(object sender, HuaweiMap.MapClickEventArgs e) | |
{ | |
selectedCoordinates.LatLng = e.P0; | |
if (circle != null) | |
{ | |
circle.Remove(); | |
circle = null; | |
} | |
AddMarkerOnMap(); | |
} |