Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Google-Maps
I have uses a class for showing map in aspx page.. And i have send a datatable from cs page..
Next thing is .I just want to display a message on click of every marker.
 
the code of class is just below...
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
 
/// <summary>
/// Summary description for GPSLib
/// </summary>
public static class gmap
{
    public static String PlotGPSPoints(DataTable tblPoints)
    {
        try
        {
            String Locations = "";
            String sJScript = "";
            int i = 0;
            foreach (DataRow r in tblPoints.Rows)
            {
                // bypass empty rows
                if (r["lat"].ToString().Trim().Length == 0)
                    continue;
 
                string Latitude = r["long"].ToString();
                string Longitude = r["lat"].ToString();
                string name = r["Name"].ToString();
 
                // create a line of JavaScript for marker on map for this record
                Locations += Environment.NewLine + @"
                path.push(new google.maps.LatLng(" + Latitude + ", " + Longitude + @"));
 
                var marker" + i.ToString() + @" = new google.maps.Marker({
                    position: new google.maps.LatLng(" + Latitude + ", " + Longitude + @"),
                    title: 'Click to see' ,
                    map: map
                });";
                i++;
            }
 
            // construct the final script
            sJScript = @"<script type='text/javascript'>
 
            var poly;
            var map;
 
            function initialize() {
                var cmloc = new google.maps.LatLng(22.5697, 88.3697);
                var myOptions = {
                    zoom: 11,
                    center: cmloc,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };
 
                map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
 

 
                var polyOptions = {
                    strokeColor: 'blue',
                    strokeOpacity: 0.0,
                    strokeWeight: 0
                }
                poly = new google.maps.Polyline(polyOptions);
                poly.setMap(map);
 
                var path = poly.getPath();
 
               " + Locations + @"
 
                  }
 

 
                </script>";
            return sJScript;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
}
Posted 28-Mar-13 20:58pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

http://www.aspsnippets.com/Articles/ASPNet-Google-Maps-V3-with-Multiple-Markers-Database-Example.aspx
 

i have solved my problem succesfully..
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 220
2 DamithSL 190
3 Raul Iloc 185
4 Richard MacCutchan 175
0 OriginalGriff 5,130
1 DamithSL 4,197
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 24 Nov 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100