• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

nuitsjp/Xamarin.Forms.GoogleMaps.Bindings

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

nuitsjp/Xamarin.Forms.GoogleMaps.Bindings

开源软件地址(OpenSource Url):

https://github.com/nuitsjp/Xamarin.Forms.GoogleMaps.Bindings

开源编程语言(OpenSource Language):

C# 100.0%

开源软件介绍(OpenSource 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.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap