This project is read-only.

AddressNotFound Feature

Nov 8, 2009 at 6:31 PM

Hi,


It mentions n the features about the AddressNotFound. I can't see it documented any where. Has anyone used this feature yet or can point me in the right direction?


Thanks in advance

Nov 9, 2009 at 6:59 AM

Hi,

You can take a look at the short video about that feature here

Regards

Nov 9, 2009 at 8:23 AM

Velio, when I use my own implementation of search, the map doesn't zoom to the right level like Google's own search bar.  If you search for a small town at world zoom level the map stays at the same zoom level.  Google must be using an algorithm to change the zoom level according the the size of the place you are searching for.  Do you know of any way around this?

Thanks

Nov 9, 2009 at 12:29 PM
Edited Nov 9, 2009 at 12:31 PM

Hi,

First, You can use the Google Maps API function getBoundsZoomLevel(GLatLngBounds bounds).
You can access that by GMap reference of the Google Map control class GoogleMap.

For example, if your GoogleMap control on the page has ID="GoogleMap1",  the JS line should looks like:

GoogleMap1.GMap.getBoundsZoomLevel(bounds);

Of course, in that case you should know the bounds of the found object.

Second, You can use the Google Maps API function showMapBlowup(GLatLng point,  GInfoWindowOptions opts)
JS line, should look like:

GoogleMap1.GMap.showMapBlowup(GoogleMap1.GMap.getCenter());

More details you can find at Google Maps API reference here.

Hope this helps.

Regards

Nov 9, 2009 at 12:38 PM

Hi,

 

Thanks for the quick reply. I've tried what you have shown in your video but still does not work I get and error:

CS0308: The non-generic type 'Artem.Web.UI.Controls.GoogleEventArgs' cannot be used with type arguments

 e.Value does not seem to appear in the intellisense

This is what I have:

  protected void HandleAny(object sender, Artem.Web.UI.Controls.GoogleEventArgs e)
    {
        
        
    }
 
On map:-

DefaultAddress
<font size="2" color="#ff0000"><font size="2" color="#ff0000"></font></font><font size="2" color="#ff0000"></font>

 
="UK" OnAddressNotFound="HandleAny">

 

 

-

 Any pointers much appreciated.

 

Thanks

Nov 9, 2009 at 4:14 PM

Hi,

You should use Artem.Web.UI.Controls.GoogleAddressEventArgs instead of Artem.Web.UI.Controls.GoogleEventArgs
Your method hadling the event should look like:

protected void HandleAddressNotFound(object sender, Artem.Web.UI.Controls.GoogleAddressEventArgs e){
    // TODO your code here
}

Regards

 

 

Nov 9, 2009 at 4:24 PM
Edited Nov 9, 2009 at 5:05 PM

Hi,

I'm sure thats not show in your video? I've tried your code and debugged, doesn't seem to get executed.

 

DefaultAddress

="UK" OnAddressNotFound="HandleAddressNotFound"
and used your code and nothing, am i missing anything else?
Cheers
Sorry got it working, What I wanted to do was display a message in a label saying that address does not exist. 
But the page just keeps refreshing if address is not found
Nov 9, 2009 at 8:53 PM

Hi,

I've tried your code in your sample project and it seems to work ok except it seems to get stuck in a loop. When I debug it seemd to get stuck in this:-

    protected void HandleAddressNotFound(object sender, Artem.Web.UI.Controls.GoogleAddressEventArgs e)
    {
        
        Label1.Text = "Error";
    
    }
What I am trying to achieve is when I click on a button to add the destination to the map is to check if it exists. If it doesn't display a message in a label.
Thanks
Nov 10, 2009 at 7:06 AM

Hi,

First of all, if you took closer look to the video about "Address Not Found" features, you probably mentioned I have started by setting a DefaultAddress for the map.
That's a crutial part, that's why your code is cycling, control will check and find the address is not found, but then there is no DefaultAddress to use instead the wrong one and show on the map.

Please, take a closer look to the GoogleMap Control 4.0 Beta release, where those features were introduces for first time and you will find next:

  • Address Not Found features:
    • DefaultAddress property which can be set and control will use when address not found.
    • OnAddressNotFound server side event.
    • OnClientAddressNotFound client side event.
    • Check out this short video GoogleMap Control "Address Not Found" features

    As you can see I'm starting with DefaultAddress there too.

    I'm sorry for the short documentation and videos, but that's the time I can spend on them.
    However, I hope if you watch them carefull and don't miss details you can work it out.

    About the EventArgs argument used on event handling method, you are right, it is not correct.
    I did that video using version 4.0 beta. Later I have changed the generic GoogleEventArgs to a dedicated GoogleAddressEventArgs.

    I will fix the video, or at least put warning messages there about that, as soon as possible.

    Regards

     

  • Nov 10, 2009 at 9:04 AM
      Hi,

     

     

    Thanks for the reply, I have set the defaultaddress for the map, in my previous post there is a snippet which includes this. This is my complete google tag:-

      
      <cc1:GoogleMap ID="GoogleMap1" runat="server" Width="400px" Height="400px"
                    Latitude="52.96187505907603" Longitude="-1.7138671875"   
                    DefaultAddress="UK" OnAddressNotFound="HandleAddressNotFound">
    
    
        protected void HandleAddressNotFound(object sender, Artem.Web.UI.Controls.GoogleAddressEventArgs e)
        {
            
            Label1.Text = "Error";
      
        }
    I've folloed your video step by step. First I add the defaultaddress="UK" I enter an address which does not exist and then hit enter, works great takes me to the UK.
    I then add the event handler GoogleAddressEventsArgs and it keeps looping. I've tried debugging and the same. What else Can I be missing? I've done all of this work in your sample website 2.0
    Many thanks
    
    Nov 10, 2009 at 9:29 AM

    Hmmm,

    Could you try with something a little bit more specific for DefaultAddress?
    For example, London England or London UK.

    Regards

    Nov 10, 2009 at 9:38 AM

    Hi,

    Tried that, and still the same:-

      <artem:GoogleMap ID="GoogleMap1" runat="server" Latitude="42.1229" Longitude="24.7879"
            Zoom="5" ShowScaleControl="true" OnClick="HandleClick" DefaultAddress="London UK" OnAddressNotFound="HandleAddressNotFound" >
        </artem:GoogleMap>
    

    I think the default address works fine, once I remove 

    OnAddressNotFound="HandleAddressNotFound"
    

    It will go to the default address. I can send you a screen recording if you want?

     

    <font size="2" color="#ff0000"><font size="2" color="#ff0000">

    Cheers

    </font></font><font size="2" color="#ff0000">

     

    </font>

     

    Nov 10, 2009 at 12:02 PM

    Hi,

    I will investigate that issue.
    What's the release version you are using?

    Regards

    Nov 10, 2009 at 12:09 PM

    Thanks, I'm using 4.0.1.0 dll

    Nov 18, 2009 at 2:07 PM

    Hi,

    I was wondering if there was any more news on this as I am currently using this control in a project.


    Thanks

    Nov 20, 2009 at 7:25 AM

    Hi,

    I'm in an extremely busy week :(.
    However, my plan is this weekend to finish and issue release 4.1.
    I will investigate and fix that problem for the new release.

    Regards

    Nov 25, 2009 at 1:17 PM

    Hi,

    I've just tried the new release and still get the same issue:-

     

     

    <font size="2">

     

    </font>

     

    <artem:GoogleMap ID="GoogleMap1" runat="server" Latitude="42.1229" Longitude="24.7879" Zoom="5" ShowScaleControl="true" OnClick="HandleClick" OnAddressNotFound="HandleAddressNotFound" DefaultAddress="London UK" >  </artem:GoogleMap>

        protected void HandleAddressNotFound(object sender, Artem.Web.UI.Controls.GoogleAddressEventArgs e)
        {
            Label1.Text = "Error";
        }
    

     

     

     

    Still get the same, gets stuck in a loop, i've also trued clearing the textfield.

     

    Cheers 

     

    Nov 25, 2009 at 1:35 PM

    Hi,

    Found away around it,

     In ths HandleAddressNotFound i put the below

    <font size="2">

    GoogleMap1.Address =

    </font>

    "London,UK";

    Allows me to display error message and not have any javascript errors

     

     

    Nov 25, 2009 at 3:03 PM

    Hi,

    Sorry to post again, but is there away to check if an address was successfully found?

     

    Thanks

    Nov 27, 2009 at 12:51 PM

    Hi Velio,

    Sorry to be a pain but is there a method to find out if an address is valid?

    Thanks

    Nov 27, 2009 at 7:28 PM
    Edited Nov 27, 2009 at 8:00 PM

    Hi,

    I have added Geocoding support just to make enable to set map or markers using addresses, for convenience.
    Didn't mean that to be used to validate addresses.
    The proper and fast way to use google map and markers will be to use Latitude&Longitute.

    So, when you using addresses you should have in mind next:
     - It's much slower (Google Geocoding will be incoked on client-side);
     - There is a limitation on using Geocoding like number of request can be done per domain per 24 hours etc.;
     - There is a limitation of number of request can be made to Geocoding per second;

    For example ,one of the issues I have fix in current release was for missing markers, not properly created. markers when they are more tran 10 etc.
    Those issues I mean:
     - Subsequent markers don't show after unsuccessful geocode
     - Issue with creating large number of Markers

    Actually the problem was when more markers with addresses were use and because the limitation of requests per second can be made to Geocoding.
    I have solved that adding a limited resolve loop with increasing timeout when address not resolved.
    In other words the idea was: if some of the markers is not resolved, I receive error from Geocoding, I put 100 millis timeout and after that asking again Geocoder.
    If fail again, increase timeout by additional 100 millis, and try again, and that a limited times  - actually 6.
    That way, if we have reached our limit to give some time to Geocoder, before asking again.

    To see how I check the address is valid you can take a look in the JS class Arte.Web.Geocoder in GoogleMap-4.1.js file.
    If geocoder didn't resolved the address by some reason, not existing or limitation, instead of the GLatLng we receive null.
    Of course, that's JS implementation and it is for the client side.
    Here is the code of Artem.Web.Geocoder:

    Artem.Web.Geoloader = function Artem$Web$Geoloader(geocoder, callback) {
        this._init(geocoder, callback);
    };
    
    Artem.Web.Geoloader.prototype = {
    
        // Fields -------------------------------------------------------------------------------------
    
        _callback: null,
        _count: 0,
        _delegate: null,
        _geocoder: null,
        _index: 0,
        _markers: [],
    
        // Methods ------------------------------------------------------------------------------------
    
        _init: function Artem$Web$Geoloader$_init(geocoder, callback) {
            this._callback = callback;
            this._delegate = Function.Delegate.create(this, this.resolve);
            this._geocoder = geocoder;
        },
    
        addMarker: function Artem$Web$Geoloader$addMarker(marker) {
            this._markers.push(marker);
        },
    
        load: function Artem$Web$Geoloader$load() {
            if (this._markers.length > 0) {
                this._index = (this._markers.length - 1);
                var marker = this._markers[this._index];
                this._geocoder.getLatLng(marker.Address, this._delegate);
            }
            else if (this._callback) {
                this._callback();
            }
        },
    
        resolve: function Artem$Web$Geoloader$resolve(point) {
            if (point) {
                this._markers[this._index].load(point);
                this._index--;
                if (this._index >= 0) {
                    this._count = 0;
                    this._geocoder.getLatLng(this._markers[this._index].Address, this._delegate);
                }
                else if (this._callback) {
                    this._callback();
                }
            }
            else {
                if (this._count < 6) {
                    var delay = this._count * 100;
                    this._count++;
                    setTimeout(delay, function() { });
                    this._geocoder.getLatLng(this._markers[this._index].Address, this._delegate);
                }
                else if ((this._index--) >= 0) {
                    this._count = 0;
                    this._geocoder.getLatLng(this._markers[this._index].Address, this._delegate);
                }
            }
        },
    
        // Type ---------------------------------------------------------------------------------------
        __type: "Artem.Web.Geoloader"
    };
    

     

    TO BE CONTINUED ...
     

    Nov 27, 2009 at 7:54 PM
    Edited Nov 27, 2009 at 7:57 PM

    Following the post above, I would suggest to all of you, when you have addresses to resolve them to Latitude/Longitude,save and use instead.
    In current GoogleMap control implementation the address is resolved on client side.
    Then Latitude and Longitude are saved in the properties of the map or marker and persited to the server on next post back.
    The weakness of that approach is: it requires a postback.

    And from some time I think to inclide in GoogleMap Control library a class (something like Geocoder),
    which can be used from server side code to invoke the Google Geocding service and resolve addresses agains it.
    I have implemented a server side (C# code) Geocoding client for the sake of one other project.
    So, I will tune up the code and add it as a part of some of th enext releases.

    I have just created a new work item in Issue Tracker here.
    So, for all of you which need that, please, vote for that work item.
    The number of votes mainly will make me dicide how soon to add that to GoogleMap Control assembly.


    Regards

    Nov 30, 2009 at 10:45 AM

    Hi Velio

     

    Thanks for the detailed reply, its really appreciated.

     

    As I mentioned before I am ¾ of the way through a project using your control and really need some way of checking if an address or postcode is valid.

     

    This is what I am working on.

     

    I’m using your control to get the mileage between locations which are specified in a drop down. The user adds the location to a grid which in turn populates the route. The route user’s longitude and latitude coordinates. What I need to do is check that the location exists before adding it to the grid.

     

    If you can help me resolve this issue it would be greatly appreciated.

    Dec 10, 2009 at 9:49 AM

    Hi Velio

    I have tried to use AddressNotFound event in the process of loading multiple directions as below.

    On ASPX page i have written this code.

    <artem:GoogleMap  ID="GoogleMap2" runat="server" Width="530px" Height="500px" Latitude="37.559819" EnableMarkerManager="true" 

      Longitude="-122.210540" Zoom="4"  BorderStyle="Solid" BorderColor="#999999" BorderWidth="1" DefaultAddress="Delhi India"  OnAddressNotFound="HandleAddressNotFound">

                <Directions>

                    <artem:GoogleDirection RoutePanelId="route" Query="from: asdfg to: asdfg to: asdfg" />

                </Directions>

        </artem:GoogleMap></div>

        <div id="route"></div>

    On corresponding .CS file  event was handled.

    protected void HandleAddressNotFound(object sender,  Artem.Web.UI.Controls.GoogleAddressEventArgs e)

        {

        }

    However this event is not firing. I am using 4.1 version of the dlls.

    Please help me out am i missing out on some thing.

    Regards

    Somil

     

    Dec 11, 2009 at 7:01 PM

    Hi,

    I believe the 

    GoogleMap1.Address = "London";

    Fires the address not found, if you have a look further up thread there is a link to a video explaining the HandleAddressNotFound.

    Cheers
    Dec 16, 2009 at 7:07 AM

    Hi

    AddressNotFound event is fired for the GoogleMap address only for now.
    It was mainly done to avoid "gray" maps when some custom addresses are added and not sure they are valid.
    That's why there is a default address property, which to be used when the address for the map is not found then default address is used in order to avoid a blank map.

    The event is not implemented to work for directions, that's why it is not fired.
    If you take a look at my short video about AddressNotFound I used it only on GoogleMap control, not on markers, directions etc.

    Regards

    Dec 16, 2009 at 12:56 PM

    Oops!!!

    Velio, is their any way I can implement that AddressNotFound feature for directions in my application.

    Regards