Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploading sample #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Binary file not shown.
27 changes: 27 additions & 0 deletions Sample/GMapUtilityDemo.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2009
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GMapUtilityDemo", "GMapUtilityDemo\GMapUtilityDemo.csproj", "{8256F46C-1C7F-4596-8542-04848532D0DC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8256F46C-1C7F-4596-8542-04848532D0DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8256F46C-1C7F-4596-8542-04848532D0DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8256F46C-1C7F-4596-8542-04848532D0DC}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{8256F46C-1C7F-4596-8542-04848532D0DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8256F46C-1C7F-4596-8542-04848532D0DC}.Release|Any CPU.Build.0 = Release|Any CPU
{8256F46C-1C7F-4596-8542-04848532D0DC}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {52215C4E-383F-4529-B6F6-38690C2473AA}
EndGlobalSection
EndGlobal
19 changes: 19 additions & 0 deletions Sample/GMapUtilityDemo/Assets/AboutAssets.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Any raw assets you want to be deployed with your application can be placed in
this directory (and child directories) and given a Build Action of "AndroidAsset".

These files will be deployed with you package and will be accessible using Android's
AssetManager, like this:

public class ReadAsset : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);

InputStream input = Assets.Open ("my_asset.txt");
}
}

Additionally, some Android functions will automatically load asset files:

Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
41 changes: 41 additions & 0 deletions Sample/GMapUtilityDemo/ClusterItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.Gms.Maps.Model;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Com.Google.Maps.Android.Clustering;

namespace GMapUtilityDemo
{
public class ClusterItem : Java.Lang.Object, IClusterItem
{
public ClusterItem(Tree tree)
{
Tree = tree;
Position = new LatLng(tree.Lat, tree.Lon);
Title = tree.Name;
Snippet = tree.Description;
}

public ClusterItem(IntPtr handle, Android.Runtime.JniHandleOwnership transfer)
: base(handle, transfer)
{

}

public LatLng Position { get; set; }

public string Snippet { get; set; }

public string Title { get; set; }

public Tree Tree { get; set; }
}
}
173 changes: 173 additions & 0 deletions Sample/GMapUtilityDemo/GMapUtilityDemo.csproj

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions Sample/GMapUtilityDemo/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using Android.App;
using Android.OS;
using Android.Gms.Maps;
using Com.Google.Maps.Android.Clustering;

namespace GMapUtilityDemo
{
[Activity(Label = "GoogleMapUtilityDemo", MainLauncher = true)]
public class MainActivity : Activity, IOnMapReadyCallback
{
private GoogleMap _map;
private ClusterManager _clusterManager;


protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);

SetContentView(Resource.Layout.Map);

MapFragment mapFragment = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map);
mapFragment.GetMapAsync(this);
}


/// <summary>
/// Called when map is ready.
/// </summary>
/// <param name="googleMap">The google map.</param>
public void OnMapReady(GoogleMap googleMap)
{
_map = googleMap;

if (_map != null)
{
// Initializing and setting up the ClusterManager and calling AddClusterItem method.
_clusterManager = new ClusterManager(this, _map);
_map.SetOnCameraIdleListener(_clusterManager);
_map.SetOnMarkerClickListener(_clusterManager);

AddClusterItems();
}
}


/// <summary>
/// Adds the cluster item to the ClusterManager.
/// Example method from: https://developers.google.com/maps/documentation/android-api/utility/marker-clustering
/// </summary>
private void AddClusterItems()
{
// Set some lat/lng coordinates to start with.
double lat = 51.5145160;
double lng = -0.1270060;

// Add ten cluster items in close proximity, for purposes of this example.
for (int i = 0; i < 10; i++)
{
double offset = i / 60d;
lat = lat + offset;
lng = lng + offset;

Tree tree = new Tree("Tree", lat, lng, "This is tree");

_clusterManager.AddItem(new ClusterItem(tree));
}
}
}

}

17 changes: 17 additions & 0 deletions Sample/GMapUtilityDemo/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="GMapUtilityDemo.GMapUtilityDemo" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="18" android:targetSdkVersion="24" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />

<!-- Permissions -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

<application android:allowBackup="true" android:label="@string/app_name">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyDzdKs7IFNVpiWeO-Aca2P0_RgE38330dU"/>
</application>

</manifest>
30 changes: 30 additions & 0 deletions Sample/GMapUtilityDemo/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Android.App;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("GMapUtilityDemo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GMapUtilityDemo")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
44 changes: 44 additions & 0 deletions Sample/GMapUtilityDemo/Resources/AboutResources.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Images, layout descriptions, binary blobs and string dictionaries can be included
in your application as resource files. Various Android APIs are designed to
operate on the resource IDs instead of dealing with images, strings or binary blobs
directly.

For example, a sample Android app that contains a user interface layout (main.axml),
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
would keep its resources in the "Resources" directory of the application:

Resources/
drawable/
icon.png

layout/
main.axml

values/
strings.xml

In order to get the build system to recognize Android resources, set the build action to
"AndroidResource". The native Android APIs do not operate directly with filenames, but
instead operate on resource IDs. When you compile an Android application that uses resources,
the build system will package the resources for distribution and generate a class called "R"
(this is an Android convention) that contains the tokens for each one of the resources
included. For example, for the above Resources layout, this is what the R class would expose:

public class R {
public class drawable {
public const int icon = 0x123;
}

public class layout {
public const int main = 0x456;
}

public class strings {
public const int first_string = 0xabc;
public const int second_string = 0xbcd;
}
}

You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
to reference the layout/main.axml file, or R.strings.first_string to reference the first
string in the dictionary file values/strings.xml.
6 changes: 6 additions & 0 deletions Sample/GMapUtilityDemo/Resources/layout/Map.axml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.google.android.gms.maps.MapFragment"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
4 changes: 4 additions & 0 deletions Sample/GMapUtilityDemo/Resources/values/Strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">GMapUtilityDemo</string>
</resources>
18 changes: 18 additions & 0 deletions Sample/GMapUtilityDemo/Tree.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace GMapUtilityDemo
{
public class Tree
{
public Tree(string name, double lat, double lon, string description)
{
Name = name;
Lat = lat;
Lon = lon;
Description = description;
}

public string Name { get; set; }
public double Lat { get; set; }
public double Lon { get; set; }
public string Description { get; set; }
}
}
18 changes: 18 additions & 0 deletions Sample/GMapUtilityDemo/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Xamarin.Android.Arch.Core.Common" version="1.0.0" targetFramework="monoandroid80" />
<package id="Xamarin.Android.Arch.Lifecycle.Common" version="1.0.1" targetFramework="monoandroid80" />
<package id="Xamarin.Android.Arch.Lifecycle.Runtime" version="1.0.0" targetFramework="monoandroid80" />
<package id="Xamarin.Android.Maps.Utils" version="0.5.0" targetFramework="monoandroid80" />
<package id="Xamarin.Android.Support.Annotations" version="26.1.0.1" targetFramework="monoandroid80" />
<package id="Xamarin.Android.Support.Compat" version="26.1.0.1" targetFramework="monoandroid80" />
<package id="Xamarin.Android.Support.Core.UI" version="26.1.0.1" targetFramework="monoandroid80" />
<package id="Xamarin.Android.Support.Core.Utils" version="26.1.0.1" targetFramework="monoandroid80" />
<package id="Xamarin.Android.Support.Fragment" version="26.1.0.1" targetFramework="monoandroid80" />
<package id="Xamarin.Android.Support.Media.Compat" version="26.1.0.1" targetFramework="monoandroid80" />
<package id="Xamarin.Build.Download" version="0.4.7" targetFramework="monoandroid80" />
<package id="Xamarin.GooglePlayServices.Base" version="60.1142.0" targetFramework="monoandroid80" />
<package id="Xamarin.GooglePlayServices.Basement" version="60.1142.0" targetFramework="monoandroid80" />
<package id="Xamarin.GooglePlayServices.Maps" version="60.1142.0" targetFramework="monoandroid80" />
<package id="Xamarin.GooglePlayServices.Tasks" version="60.1142.0" targetFramework="monoandroid80" />
</packages>
Binary file added Sample/Screenshots/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sample/Screenshots/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sample/Screenshots/3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading