Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Android.App;
- using Android.Content;
- using Android.OS;
- using Android.Runtime;
- using Android.Util;
- using Android.Views;
- using Android.Widget;
- using Java.Lang;
- using Android.Graphics;
- using Android.Text;
- using Android.Gms.Maps;
- using Android.Gms.Maps.Model;
- namespace WurthReservationAndroid
- {
- public class MapWrapper : RelativeLayout
- {
- private GoogleMap map;
- private int bottomOffsetPixels;
- public Marker marker;
- private View infoWindow;
- public MapWrapper(Context context) : base(context)
- {
- }
- public MapWrapper(Context context, IAttributeSet attrs) : base(context, attrs)
- {
- }
- public MapWrapper(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
- {
- }
- public MapWrapper(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
- {
- }
- public void init(GoogleMap map, int bottomOffsetPixels) {
- this.map = map;
- this.bottomOffsetPixels = bottomOffsetPixels;
- }
- public void setMarkerWithInfoWindow(Marker marker, View infoWindow) {
- this.marker = marker;
- this.infoWindow = infoWindow;
- }
- public override bool DispatchTouchEvent (MotionEvent ev)
- {
- bool ret = false;
- // Make sure that the infoWindow is shown and we have all the needed references
- if (marker != null && marker.IsInfoWindowShown && map != null && infoWindow != null) {
- // Get a marker position on the screen
- Point point = map.Projection.ToScreenLocation(marker.Position);
- // Make a copy of the MotionEvent and adjust it's location
- // so it is relative to the infoWindow left top corner
- MotionEvent copyEv = MotionEvent.Obtain(ev);
- copyEv.OffsetLocation(
- -point.X + (infoWindow.Width / 2),
- -point.Y + infoWindow.Height + bottomOffsetPixels);
- // Dispatch the adjusted MotionEvent to the infoWindow
- ret = infoWindow.DispatchTouchEvent(copyEv);
- //detect click en voyant la différence, si c'est entre -18dp et -60dp et -125 et +125, infowindo custom où on appel showInfoWindow
- }
- // If the infoWindow consumed the touch event, then just return true.
- // Otherwise pass this event to the super class and return it's result
- return ret || base.DispatchTouchEvent(ev);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement