Click here to Skip to main content
12,078,070 members (46,940 online)
Rate this:
 
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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web03 | 2.8.160212.1 | Last Updated 24 Nov 2013
Copyright © CodeProject, 1999-2016
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