ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์Programmingช่วยด้วยคับ แก้มุดแล้วเป็นแบบนี้ Google Map !!
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: ช่วยด้วยคับ แก้มุดแล้วเป็นแบบนี้ Google Map !!  (อ่าน 824 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
mkcrazy
Newbie
*

พลังน้ำใจ: 0
ออฟไลน์ ออฟไลน์

กระทู้: 1



ดูรายละเอียด
« เมื่อ: 20 มิถุนายน 2010, 18:45:33 »

คือผม เปลี่ยน หมุด เป็น icon อื่น แล้วทำการดึงหมุดจาก DB ทำเป็น MVC อะคับ แล้วกำหนดแต่ลหะมุดให้ดึงข้อมูลมาโชว์แล้วทีนี้ กดหมุดอื่นๆมันจะโชว์ข้อมูลที่หมุดเดียวอะคับ ช่วยด้วยคั�
อ้างถึง
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<List<GGmapstest.Models.Tweet>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Home Page
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
   
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd ">
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Google Maps</title>
    <script src="http://maps.google.com/maps?fi...ThQYkcZUPRJn9vy_TWxWvuLoOfSFBw " type="text/javascript"></script>
  </head>
  <body onunload="GUnload()">
 
    <div id="map" style="width: 550px; height: 450px"></div>

 
 
    <noscript><b>JavaScript must be enabled in order for you to use Google Maps.</b>
      However, it seems JavaScript is either disabled or not supported by your browser.
      To view Google Maps, enable JavaScript by changing your browser options, and then
      try again.
    </noscript>
 
 
    <script type="text/javascript">
    //<![CDATA[

       if (GBrowserIsCompatible()) {

            // A function to create the marker and set up the event window
            // Dont try to unroll this function. It has to be here for the function closure
            // Each instance of the function preserves the contends of a different instance
            // of the "marker" and "html" variables which will be needed later when the event triggers.   
           function createMarker(point, html) {
                var marker = new GMarker(point);
                GEvent.addListener(marker, "click", function () {
                    marker.openInfoWindowHtml(html);
                });
                return marker;
            }


         
            // Display the map, with some controls and set the initial location
            var map = new GMap2(document.getElementById("map"));
            map.addControl(new GLargeMapControl());
            map.addControl(new GMapTypeControl());
            map.setCenter(new GLatLng(18.816123,98.968792), 13);
            map.setMapType(G_NORMAL_MAP);

           
            // My custom marker icon
            var myIcon = new GIcon();
            myIcon.image = 'markers/image.png';
            myIcon.shadow = 'markers/shadow.png';
            myIcon.iconSize = new GSize(20, 20);
            myIcon.shadowSize = new GSize(30, 20);
            myIcon.iconAnchor = new GPoint(10, 20);
            myIcon.infoWindowAnchor = new GPoint(10, 0);
            myIcon.printImage = 'markers/printImage.gif';
            myIcon.mozPrintImage = 'markers/mozPrintImage.gif';
            myIcon.printShadow = 'markers/printShadow.gif';
            myIcon.transparent = 'markers/transparent.png';
            myIcon.imageMap = [16, 0, 16, 1, 15, 2, 16, 3, 17, 4, 17, 5, 18, 6, 19, 7, 19, 8, 19, 9, 19, 10, 17, 11, 15, 12, 15, 13, 16, 14, 17, 15, 18, 16, 19, 17, 19, 18, 19, 19, 0, 19, 0, 18, 0, 17, 1, 16, 2, 15, 3, 14, 4, 13, 4, 12, 2, 11, 0, 10, 0, 9, 0, 8, 0, 7, 1, 6, 2, 5, 2, 4, 3, 3, 4, 2, 5, 1, 6, 0];

       

            // Set up our GMarkerOptions object literal
            markerOptions = { icon: myIcon};
         
            //GEvent.addListener(marker, "click", function() {
            //marker.openInfoWindowHtml('asd');
            //});



            /*
            // Add 10 markers to the map at random locations
            var bounds = map.getBounds();
            var southWest = bounds.getSouthWest();
            var northEast = bounds.getNorthEast();
            var lngSpan = northEast.lng() - southWest.lng();
            var latSpan = northEast.lat() - southWest.lat();
            for (var i = 0; i < 10; i  ) {
                var point = new GLatLng(southWest.lat()   latSpan * Math.random(),
                          southWest.lng()   lngSpan * Math.random());
                map.addOverlay(new GMarker(point, markerOptions));
            }*/
       

       
            <% foreach(var tweet in Model){ %>
   
             var point = new GLatLng(<%= tweet.Latitude %>, <%= tweet.Longitude %>);
             var marker = new GMarker(point,{icon: myIcon});
             //var marker = createMarker(point,'<div style="width:240px"><%= tweet.Text %><%= tweet.Report.Name %></div>')
             map.addOverlay(marker);
             
             //map.addOverlay(new GMarker(point, markerOptions));
             GEvent.addListener(marker, "click", function() {
             marker.openInfoWindowHtml('<%= tweet.Text %><%= tweet.Report.Name %></div>');
             });
            <%} %>

        }

        // display a warning if the browser was not compatible
        else {
            alert("Sorry, the Google Maps API is not compatible with this browser");
        }

        // This Javascript is based on code provided by the
        // Community Church Javascript Team
        // http://www.bisphamchurch.org.uk/    
        // http://econym.org.uk/gmap/
 
    //]]>
    </script>
  </body>
 
</html>
 
 
 
 
</asp:Content>
บันทึกการเข้า
หน้า: [1]   ขึ้นบน
พิมพ์