Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Windows Store Apps > Windows Store and Maps (C#) > Windows Store Apps and Bing Maps SDK (C#)



Clound SSD Virtual Server

Windows Store Apps and Bing Maps SDK (C#)

Windows Store Apps and Bing Maps SDK (C#) ในการเขียน Apps บน Windows Store Apps เพื่อติดต่อกับ Maps หรือ แผนที่นั้น ปัจจุบันยังมีเพียง Bing Maps เท่านั้นที่สามารถเรียกใช้ได้ โดยมีการออก Bing Maps SDK for Windows Store Apps ได้มาซะพักแล้ว ส่วน Google Maps นั้น ณ ตอนนี้ยังไม่มีการออก SDK แต่อย่างใด ไว้ออกมาเมื่อไหร่ จะรีบนำมา Review ให้ทราบโดยเร็ว สำหรับรูปแบบการใช้งาน Bing Maps บน Windows Store Apps นั้นก็ต้องบอกว่าหลังจากที่ SDK ออกมาเรียบร้อยแล้วนั้น สามารถเรียกใช้งานได้ง่ายมาก เพียงแค่ติดตั้ง SDK ผ่าน NuGet Package ของ Visual Studio จากนั้นก็สามารถที่จะเรียก Maps ขึ้นมาแสดงบน Apps ได้ด้วยการเขียน Code เพียง 2-3 บรรทัดเท่านั้น

Windows Store Apps and Bing Map SDK (C#)

Bing Maps


ก่อนการเรียกใช้งาน Bing Maps นั้เราจะต้องมี Bing Maps Keys ซะก่อน ซึ่ง Key นี้เราสามารถสมัครและขอมาใช้ได้ฟรี แต่การใช้ Maps นั้นก็จะมีข้อจำกัดสำหรับ Account ที่เป็นบบฟรี เช่น สามารถเรียกใช้ได้กี่ครั้งต่อเดือน หรือ สามารถปักหมุดสูงสุดได้กี่จุด โดยรายละเอียดต่าง ๆ เหล่านั้นสามารถสมัครและอ่านได้ที่


โดยการสมัครนั้นสามารถใช้ Account ของ Microsoft Account เช่นพวก Hotmail , MSN ได้ทันที

Windows Store Apps and Bing Map SDK (C#)

เริ่มต้นการสมัคร API Key ของ Bing Map คลิกที่ Sign in

Windows Store Apps and Bing Map SDK (C#)

เลือก Continue

Windows Store Apps and Bing Map SDK (C#)

กรอกรายละเอียดของ Account

Windows Store Apps and Bing Map SDK (C#)

หลังจากนั้นให้คลิกที่ Create or view keys พร้อมกับกรอกรายละเอียดต่าง ๆ ของ Application ที่จะเรียกใช้

Windows Store Apps and Bing Map SDK (C#)

ตอนนี้เราจะได้ Keys ที่พร้อมจะนำไปใช้กับ Windows Store Apps








การติดตั้ง Bing Map SDK for Windows 8.1 Store Apps

สำหรับขั้นตอนนี้สามารถติดตั้งได้จาก NuGet Package หรือจะ Download ผ่าน

Windows Store Apps and Bing Map SDK (C#)

Bing Map SDK for Windows 8.1 Store Apps
http://visualstudiogallery.msdn.microsoft.com/224eb93a-ebc4-46ba-9be7-90ee777ad9e1

ตรวจสอบ Version ให้ถูกต้องด้วย ระหว่าง Visual Studio 2012 หรือ 2013

Windows Store Apps and Bing Map SDK (C#)

ติดตั้ง Bing Map SDK

Windows Store Apps and Bing Map SDK (C#)

เลือก Install

Windows Store Apps and Bing Map SDK (C#)

กำลังติดตั้ง

Windows Store Apps and Bing Map SDK (C#)

ติดตั้งเรียบร้อยแล้ว


การเรียกใช้งาน Bing Maps SDK บน Visual Studio

Windows Store Apps and Bing Map SDK (C#)

คลิกขวาที่ Reference เลือก Add Reference

Windows Store Apps and Bing Map SDK (C#)

เลือก Windows -> Extensions -> Bing Map for C# ....

Windows Store Apps and Bing Map SDK (C#)

ถ้าขึ้น Warning ดังรูป ให้ปรับรุ่นของ CPU ให้เป็น x86 หรือ x64

Windows Store Apps and Bing Map SDK (C#)

ไปที่ Build -> Confuguration Manager

Windows Store Apps and Bing Map SDK (C#)

เลือกรุ่นของ CPU ปรับเป็นรุ่นอื่น ๆ นอกเหนือจาก Any CPU

Windows Store Apps and Bing Map SDK (C#)

ตอนนี้ Warning หายไปแล้ว ซึ่งขั้นตอนถัดไปเราสามารถเรียกใช้งาน Bing Maps ได้แล้ว

ขั้นตอนการเรียกใช้งาน Bing Map

Windows Store Apps and Bing Map SDK (C#)

เพิ่ม Tag ว่า

xmlns:bm="using:Bing.Maps"


และ

<bm:Map Credentials="INSERT_YOUR_BING_MAP_KEY" x:Name="myMap"></bm:Map>


INSERT_YOUR_BING_MAP_KEY คือ API Key ที่ได้สมัครไว้ก่อนหน้านี้

Windows Store Apps and Bing Map SDK (C#)

ทดสอบการรันบน Simulator

Windows Store Apps and Bing Map SDK (C#)

แสดง Bing Maps บน Windows Store Apps

หรือจะเขียนเงื่อนไขการแสดงผลบน C# เช่น

MainPage.xaml
<Page
    x:Class="WindowsStoreApps.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:WindowsStoreApps"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:bm="using:Bing.Maps">


    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

        <bm:Map Credentials="INSERT_YOUR_BING_MAP_KEY" x:Name="myMap" 
             MapType="Aerial" ZoomLevel="12"
             Width="600" Height="800">
                <bm:Map.Center>
                    <bm:Location Latitude="13.716667" Longitude="100.516670" />
                </bm:Map.Center>
        </bm:Map>

    </Grid>
</Page>

MainPage.xaml.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Devices.Geolocation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

using Bing.Maps;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace WindowsStoreApps
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    /// 

    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
             InitializeMap();
        }


        void InitializeMap()
        {
              myMap.Center = new Location(13.716667, 100.516670);
              myMap.ZoomLevel = 12;
              myMap.MapType = MapType.Aerial;
              myMap.Width = 600;
              myMap.Height = 800;
        }  
    }


}


Windows Store Apps and Bing Map SDK (C#)

ได้ผลลัพธ์เหมือนกัน

เพิ่มเติม
The name "Map" does not exist in the namespace "using:Bing.Maps"

กรณีมี Error นี้ ให้ลบไฟล์ในโฟเดอร์ bin และ obj ออกให้หมด







.

   
Share


ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท


ลองใช้ค้นหาข้อมูล


   


Bookmark.   
       
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rating :  
  Create/Update Date : 2014-06-23 13:10:44 / 2017-03-19 15:05:12
  Download : No files
 Sponsored Links / Related

 
Windows Store Apps and Bing Maps Zoom Level / Current Location (C#)
Rating :

 
Windows Store Apps and Bing Maps / Marker Location JSON (C#)
Rating :

 
Windows Store Apps and Bing Maps / Pushpins / Marker PHP/MySQL (C#)
Rating :


ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่