Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

MapFragment - Possible reference conflict or something?

$
0
0

c:\Users\Tib90\Documents\Projects\IgluHarkka2 - TOIMII - Copy\Components\googleplayservices10-10.0\lib\android\GooglePlayServicesLib.dll: Warning CS1684: Reference to type 'Android.App.Fragment' claims it is defined in 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2\Mono.Android.dll', but it could not be found (CS1684) (IgluHarkka2)

c:\Users\Tib90\Documents\Projects\IgluHarkka2 - TOIMII - Copy\Components\googleplayservices10-10.0\lib\android\GooglePlayServicesLib.dll: Error CS0011: The base class or interface 'Android.App.Fragment' in assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' referenced by type 'Android.Gms.Maps.MapFragment' could not be resolved (CS0011) (IgluHarkka2)

What I am trying to do is add programmatical map movement and marker placement, but I keep getting these errors when I try to instantiate a MapFragment object. A normal Fragment works just fine. The map works perfectly without any of the mapfragment nonsense in the activity, so all other code is valid at the moment. I just gotta get the MapFragment _mapFragment to work properly. What does that error actually mean? I did not find much information on this.

I have the following References in my project:

  • GooglePlayServicesLib.dll ("Created by the Google Play Services Rev 10" Component)
  • Mono.Android
  • Mono.Android.Support.V4
  • System
  • System.Core
  • System.Json
  • System.Xml

And this is my whole Activity:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

using Android.App;
using Android.Locations;
using Android.OS;
using Android.Util;
using Android.Widget;
using Android.Support.V4.App;
using Android.Gms.Maps;
using Android.Gms.Maps.Model;

namespace IgluHarkka2
{
    [Activity(Label = "MapsActivity", MainLauncher = true)]
    public class MapsActivity : FragmentActivity {
        private Query q;
        private LatLng coordinates;
        private FragmentManager fm;
        private MapFragment _mapFragment;
        private GoogleMap _gMap;
        private CameraUpdate camUpdate;

        protected override void OnCreate(Bundle bundle) 
        {
            base.OnCreate(bundle);
            SetContentView (Resource.Layout.Map);

            _mapFragment = fm.FindFragmentById (Resource.Id.map);
            _gMap = _mapFragment.Map;



            EditText sText = FindViewById<EditText> (Resource.Id.et_location);
            Button fButton = FindViewById<Button> (Resource.Id.btn_find);
            fButton.Click += (sender, e) => {
                q = new Query(sText.Text);
                q.CreateQuery();
                var result = q.ResponseFromGoogle.results.Find (item => item.geometry.location.lat.ToString("F") != null);
                sText.Text = result.geometry.location.lat.ToString("F") + ", " + result.geometry.location.lng.ToString("F");
                coordinates = new LatLng(result.geometry.location.lat, result.geometry.location.lng);

                camUpdate = CameraUpdateFactory.NewLatLng(coordinates);
                _gMap.MoveCamera(camUpdate);
            };
        }
    }
}

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>