Selasa, 25 Juni 2013

Make GMaps use C#

I discribe about make Gmap using c#
you can see  Result screenshot this below.




default.ascx


<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="default.ascx.cs" Inherits="Module.GoogleMaps._default" %>
<%@ Register assembly="GMaps" namespace="Subgurim.Controles" tagprefix="cc1" %>
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=AIzaSyAn3hi9Uwq91GWH-g7ZzMaOBUd3XeyevFA&sensor=true">
<script type="text/javascript" src="http://www.google.com/jsapi?key=AIzaSyAn3hi9Uwq91GWH-g7ZzMaOBUd3XeyevFA"></script>
<script type="text/javascript">
    google.load("maps", "2.x", { "language": "en" });
</script>
<div id ="displaymap">
    <asp:Button ID="btnmap" runat ="server" Text ="map" OnClick ="btnclick_map"/>&nbsp <asp:Button ID="btnsatelite" runat ="server" Text ="Satelite" OnClick ="btnclick_satelite" /> &nbsp <asp:Button ID="btnhybrid" runat ="server" Text ="Hybrid" OnClick ="btnhybrid_click" />
</div>
<cc1:GMap ID="GMap1" runat="server" Width="1000px" Height="500px" mapType="Normal" key="AIzaSyAMWyb8ngnZhoiYwJkso2cnO9NZWT0kpHU" zoom="9"
        enableHookMouseWheelToZoom="True" />

default.ascx.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Subgurim.Controles;
using DotNetNuke.Entities.Modules;


namespace Module.GoogleMaps
{
    public partial class _default : PortalModuleBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                   
                    string skey = "AIzaSyAMWyb8ngnZhoiYwJkso2cnO9NZWT0kpHU";
                    GMap1.Key = skey;
                    GMap1.addControl(new GControl(GControl.preBuilt.GOverviewMapControl));
                    GMap1.addControl(new GControl(GControl.preBuilt.LargeMapControl));
                    //untuk mengatur scala display map
                    GMap1.setCenter(new GLatLng(0.395505, 111.441879), 5);
                    //creatig marker with latitude and longitude
                    GMarker markerjakartapusat = new GMarker(new GLatLng(-6.210122, 106.821202));

                    //creating puspin
                    GInfoWindow windowJakartaPusat = new GInfoWindow(markerjakartapusat, "<center><b>Gedung International Financial Center lantai 8</b><br>Jl. Jend. Sudirman Kav. 22-23<br>Jakarta 12920<br>Telp:021-29248900,Fax:021-5712344</center>", true);

                    //creating new marker for second location
                    GMarker markersemarang = new GMarker(new GLatLng(-6.94892, 110.415924));
                    //creating second pushpin window
                    GInfoWindow windowsemarang = new GInfoWindow(markersemarang, "<center><b>Jl. Kedondong Dalam IX No.6 Lamper Tengah, Semarang, Jawa Tengah</b><br>Telp:024-8449376,Fax:024-8449376<br>PURNAMA SIDIQ,0818 0599 9232,purnama.sidiq@tower-bersama.com</center>", true);

                    //creating new marker for jawatimur/surabaya
                    GMarker markersurabaya = new GMarker(new GLatLng(-7.271206, 112.729232));
                    //creating puspin jawatimur
                    GInfoWindow windowsurabaya = new GInfoWindow(markersurabaya, "<center><b>Jl. Sambas No. 1 Kel. Wonokromo,Surabaya 60241 ,</b><br>Telp:031-5664938,Fax:031-5684201<br>DWI PUJA SASTRA,0812 3816 6977,dpsastra@tower-bersama.com</center>", true);


                    //creating new marker for Bali/NTT
                    GMarker markerbali = new GMarker(new GLatLng(-8.358258, 115.171995));
                    //creating puspin bali
                    GInfoWindow windowsbali = new GInfoWindow(markerbali, "<center><b>Subregional : Bali-NTT</b><br>Grand Sudirman Agung Blok C No. 30 Lt. 1<br>Jl. Jendral Sudirman Panjer Denpasar Selatan,80114-Bali<br>Telp:0361-255385,Fax:0361-255386<br>DODDY  ADIANTO ,0812 2881 0088,doddy.adianto@tower-bersama.com</center>", true);


                    //creating new marker for jawabarat
                    GMarker markerjawabarat = new GMarker(new GLatLng(-6.904614, 107.61103));
                    //creating puspin jawabarat
                    GInfoWindow windowsjawabarat = new GInfoWindow(markerjawabarat, "<center><b>Jl. Cipaganti no. 47 Bandung,Jawa Barat</b><br>KUSMANA ,0817 223 113,kusmana@tower-bersama.com</center>", true);

                    //Creating new marker for sumbagut
                    GMarker markermedan = new GMarker(new GLatLng(3.614848, 98.669372));
                    //creating puspin medan
                    GInfoWindow windowsmedan = new GInfoWindow(markermedan, "<center><b>Komp. Taman Setia Budi Indah Blok C No. 12 </b><br>Kel Tanjung Rejo kec. Medan Sunggal,Medan - Sumatera Utara<br>Telp:061-8200461,Fax:061-7872471<br>TUMPAL DANIEL,0813 8413 5005/0815 1660 956,tumpal-d.mexon@tower-bersama.com</center>", true);

                    //creating new marker for sumbagsel
                    GMarker markersumbagsel = new GMarker(new GLatLng(-2.822344, 104.731808));
                    //creating puspin sumbagsel
                    GInfoWindow windowssumbagesel = new GInfoWindow(markersumbagsel, "<center><b> Jl. Angkatan 45 No. 14  Palembang,Sumatera Selatan  </b><br>Telp:0711-355215<br>DENY RAHMAT,0819 3136 5467, 0852 9451 1424,<br> 0857 617 99599,deni@tower-bersama.com</center>", true);

                    //creating new marker for pekanbaru
                    GMarker markerpekanbaru = new GMarker(new GLatLng(0.560294, 101.457024));
                    //creating puspin pekanbaru
                    GInfoWindow windowspekanbaru = new GInfoWindow(markerpekanbaru, "<center><b>SubRegional:Pekanbaru</b><br>Jl. Teratai no 20-22 RT02/Rw 02 <br>Kel.Padang Terubuk,Kec Senapelan<br>Kota Pekanbaru,Riau</b></center>", true);


                    //creating nw marker for jakarta/banten
                    GMarker markerjakartabanten = new GMarker(new GLatLng(-6.234376, 106.848686));
                    //creating puspin jakarta/banten
                    GInfoWindow windowsjakartabanten = new GInfoWindow(markerjakartabanten, "<center><b>Jl. Tebet Barat IX no. 14,Jakarta Selatan</b><br>Telp:021-8301791,Fax:021-8301791 ext. 106<br>REVO MULTIKO PUTRA,0811 8329 49,revo-m.putra@tower-bersama.com</center>", true);

                    //creating new marker for sulawesi
                    GMarker markersulawesi = new GMarker(new GLatLng(-2.921097, 120.011215));
                    //creating puspin sulawesi
                    GInfoWindow windowssulawesi = new GInfoWindow(markersulawesi, "<center><b>Jl. Sultan Alauddin Kec. Tamalate - Makassar,Sulawesi Selatan</b><br>CHANDRA NOVYAN,HP:0811 173 953/0818 111710,<br>chandra-n.nurfahmi@tower-bersama.com</center>", true);

                    //creating new marker for kalimantan
                    GMarker markerkalimantan = new GMarker(new GLatLng(0.395505, 111.441879));
                    //creating puspin kalimanatan
                    GInfoWindow windowskalimantan = new GInfoWindow(markerkalimantan, "<center><b>BUDI SATRIA</b>,0815 7391 3872 /0812 2051 5847,<br>budi.s@tower-bersama.com</center>", true);


                    //creating new marker for balikpapan
                    GMarker markerbalikpapan = new GMarker(new GLatLng(-1.229001, 116.827025));
                    //creating puspinbalikppan
                    GInfoWindow windowsbalikpapan = new GInfoWindow(markerbalikpapan, "<center><b>SubRegional:Balikpapan </b><br>Cluster Kyoto Blok BC No 41 Rt 062<br>Kel damai -balikpapan baru</center>", true);

                    //adding windows in GMap control
                    GMap1.addInfoWindow(windowJakartaPusat);
                    GMap1.addInfoWindow(windowsemarang);
                    GMap1.addInfoWindow(windowsurabaya);
                    GMap1.addInfoWindow(windowsbali);
                    GMap1.addInfoWindow(windowsjawabarat);
                    GMap1.addInfoWindow(windowsmedan);
                    GMap1.addInfoWindow(windowssumbagesel);
                    GMap1.addInfoWindow(windowspekanbaru);
                    GMap1.addInfoWindow(windowsjakartabanten);
                    GMap1.addInfoWindow(windowssulawesi);
                    GMap1.addInfoWindow(windowskalimantan);
                    GMap1.addInfoWindow(windowsbalikpapan);

                }
                catch (Exception)
                {
                }
            }
        }
        protected void btnclick_map(object sender, EventArgs e)
        {
            GMap1.mapType = GMapType.GTypes.Normal;
        }
        protected void btnclick_satelite(object sender, EventArgs e)
        {
            GMap1.mapType = GMapType.GTypes.Satellite;
        }
        protected void btnhybrid_click(object sender, EventArgs e)
        {
            GMap1.mapType = GMapType.GTypes.Hybrid;
        }
    }

}

you must add gmap.dll in reference from bin.and you can donload gmap.dll this link below

http://www.4shared.com/rar/dIF_8LpO/Gmap_dll.html?







Tidak ada komentar:

Posting Komentar