?
Solved

Update Google map through WCF Ajax Service

Posted on 2011-04-18
7
Medium Priority
?
585 Views
Last Modified: 2013-11-19
Hello,

We have scenario in project to update google map through WCF AJAX service.


1. On a aspx page I have checkbox list to filter, search results and based on search result location google map shows locations.

2. When I select checkbox to filter, search result updates and google map should also get updated.

3. Google map is not updating.

Source Code:

On checkbox selection,
var CurrentPage;
function RetrieveDiscounts(currentLocationId, discountDateRanges, pageNumber) {

INAW.AjaxServices.AjaxDiscountService.FindValidDiscounts(
                                currentLocationId, null, discountDateRanges, discountDateRanges, DiscountItems, VenueTypes, DiscountKeyword, VenueKeyword, MinValue, pageNumber,
                                PageSize, SortOrder, DiscountType, OtherDiscountType, isDisountCard, VenueName, VenueAddress, state, city, venuedistance, 1, onFindDiscountsComplete, onFindDiscountsError)
                                ;
    }

 
Ajax service source code:
 
[OperationContract]
        public string[] FindValidDiscounts(int locationId, GeoLocation userLocation, DateTime discountStartDate, DateTime discountEndDate, IEnumerable<int> discountItemIds,
                                    IEnumerable<int> venueTypesIds, string discountKeyword, string venueKeyword, double minDiscountValue, int pageNumber, byte pageSize,
                                    DiscountSearchOrder orderBy, IEnumerable<int> DiscountType, IEnumerable<int> DiscountOtherType, int Iscard, string VenueName, string VenueAddess, string State, string City, string venuedistance, Int32 isTrue)
        {

Page pageHolder = new Page();
Map omap = (Map)pageHolder.LoadControl("~/_Parts/utility/Map.ascx");
int VenueCounter = 0;
            foreach (SearchResult oSearchResult in oDiscountSearchResponse.SearchResults)
            {
                VenueCounter += 1;
                omap.AddLocation(oSearchResult.Venue.GeoLocation.Latitude, oSearchResult.Venue.GeoLocation.Longitude, VenueCounter, "");
            }

string[] str = new string[5];


            omap.SetCenter(72.12, 72.19);
            omap.ZoomLevel = 10;
            omap.Commit();

            StringWriter Mapoutput = new StringWriter();
            HttpContext.Current.Server.Execute(pageHolder, Mapoutput, false);
            str[0] = Mapoutput.ToString();

            return str;

}


When AJAX call completes

//ajax success
function onFindDiscountsComplete(results, context, methodName) {

   document.getElementById('MapContainer').innerHTML = results[0];

}

MapContainer is div tag on aspx page.
Our problem is that google map is not refreshing on ajax call.

Can any one give great thoughts over it?

Best Regards,
MohitPandit
0
Comment
Question by:MohitPandit
  • 4
5 Comments
 
LVL 13

Expert Comment

by:SameerJagdale
ID: 35430743
why don't you use Google Maps API toolkit, they have excellent functionalities.
0
 
LVL 5

Author Comment

by:MohitPandit
ID: 35439953
We have architecute like that and we need to follow this only. Do you have your great suggestions?
0
 
LVL 5

Author Comment

by:MohitPandit
ID: 35866726
Yes, I found the answer myselft for this and I will update when I will be in the office.
0
 
LVL 5

Accepted Solution

by:
MohitPandit earned 0 total points
ID: 35884467
Solution found myself:

We have to again update the JavaScript reference  and load it using Jquery  or update reference through registering the google map javascript api reference.Following is the code for this problem.


function loadScript() {

    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initialize";
    document.body.appendChild(script);
}

This will update the javascript reference for google map and will update Google map asynchrously
0
 
LVL 5

Author Closing Comment

by:MohitPandit
ID: 35910106
Found solution myself and I hope that it will helpful
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month14 days, 3 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question