GithubHelp home page GithubHelp logo

xamarin.forms.googlemaps.bindings's Introduction

This maintenance is currently suspended.

This is because developers can't take the time because of private changes. If you are a new user, please consider fork and managing it yourself.

Xamarin.Forms.GoogleMaps.Bindings

Japanese Documents

This library is the MVVM(Bindings) support library for Xamarin.Forms.GoogleMaps.
To support binding, Xamarin.Forms.GoogleMaps requires broken changes.
For this reason, major change to Xamarin.Forms.GoogleMaps to use it.

This library provides three types of functions.

  1. Behavior for bind non-binding properties to View Model
  2. Behavior when events occur, execute ICommand
  3. Function for moving the map position from ViewModel

Setup

If you cannot enable XAML Compilation.
Add the following.    

  • Install the package to your Native project
  • Add an initialization process
    global::Xamarin.Forms.Forms.Init();
    Xamarin.FormsGoogleMaps.Init(this, bundle);
    Xamarin.FormsGoogleMapsBindings.Init(); // Add this line
    LoadApplication(new App());

Usage

Learn how to touch and pin any part of the map.  

  1. Create a new Xamarin forms project and make Xamarin.Forms.Maps available
    See here.
  2. Create MainPageViewModel.cs
  3. To modify MainPage.xaml

MainPageViewModel.cs

public class MainPageViewModel
{
    public ObservableCollection<Pin> Pins { get; set; }

    public Command<MapClickedEventArgs> MapClickedCommand => 
        new Command<MapClickedEventArgs>(args =>
        {
            Pins.Add(new Pin
            {
                Label = $"Pin{Pins.Count}",
                Position = args.Point
            });
        });
}

MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:googleMaps="clr-namespace:Xamarin.Forms.GoogleMaps;assembly=Xamarin.Forms.GoogleMaps"
             xmlns:bindings="clr-namespace:Xamarin.Forms.GoogleMaps.Bindings;assembly=Xamarin.Forms.GoogleMaps.Bindings"
             xmlns:local="clr-namespace:SimplestSample;assembly=SimplestSample"
             x:Class="SimplestSample.MainPage">
  <ContentPage.BindingContext>
    <local:MainPageViewModel/>
  </ContentPage.BindingContext>
  <googleMaps:Map>
    <googleMaps:Map.Behaviors>
      <bindings:BindingPinsBehavior Value="{Binding Pins}"/>
      <bindings:MapClickedToCommandBehavior Command="{Binding MapClickedCommand}"/>
    </googleMaps:Map.Behaviors>
  </googleMaps:Map>
</ContentPage>

BindingPinsBehavior binds the Pins property of the map to ViewModel Pins.
MapClickedToCommandBehavior handles the Mapclicked event and calls the ViewModel MapClickedCommand.

Behavior to bind the property supports only the OneWayToSource.

Otherwise please see samples here.
GoogleMaps.Bindings project.

License

See LICENSE.

xamarin.forms.googlemaps.bindings's People

Contributors

nuitsjp avatar amay077 avatar pandazzurro avatar beej126 avatar damiendoumer avatar ryanrauch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.