Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Eva Tucker 3 posts 23 karma points
    Sep 01, 2011 @ 21:16
    Eva Tucker
    0

    Please provide a search term

    Hi. I am new to Umbraco and am attempting to set up the store locator package.

    I seem to have set up everything and am getting the following message on my page, "Please provide a search term"

    I see in the post about the package (http://www.nibble.be/), that a search location can be added via a query string, but can't figure out exactly where I should be coming up with what this query string should be and where I should add that in. 

    I have tried a number of options and keep getting the following error: 

    Error loading Razor Script Locator.cshtml
    Cannot perform runtime binding on a null reference

    Any guidance will be appreciated.

  • Eva Tucker 3 posts 23 karma points
    Sep 01, 2011 @ 22:05
    Eva Tucker
    0

    Well I added a form that is appending my query string to the URL, but I am still getting this error when trying to run the query:

    Error loading Razor Script Locator.cshtml
    Cannot perform runtime binding on a null reference

    (Also - We are using Umbraco 4.7.0) Thanks!

     

     

     

  • Eva Tucker 3 posts 23 karma points
    Sep 01, 2011 @ 22:46
    Eva Tucker
    0

    This is the form I am using:

       <form method="get" action="locations.aspx">
                    <p>Find a location near you:</p>
                <fieldset>
                     <label for="s">Address/postcode: </label>
                    
                    <input type="text" name="s" />
                    
                     <label for="s">Radius: </label>
                    <select name="radius">
                    <option value="0">Please select</option>
                    <option value="10">10 miles</option>
                    <option value="50">50 miles</option>
                    <option value="100">100 miles</option>
                    </select>
     
     
                  <button type="submit"><span>Go</span></button>
                </fieldset>
            </form>


    Is this correct?

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Sep 02, 2011 @ 13:35
    Tim Geyssens
    0

    And are you using the default settings, or did you set the some params? Could you show the macro tag (placed on the template) ?

  • Mike Joseph 9 posts 29 karma points
    Nov 11, 2011 @ 20:18
    Mike Joseph
    0

    Hello! I seem to be having a similar problem and am unable to get working results.

    Here's what I've done to set it up:

    • I installed the .zip package from the project page.
    • I added a property called "coordinates" of the data type "Google Map" to my Document type called "Location"
    • I setup the coordinates in each of my "Location" nodes. 
    • I inserted the Locator Macro using the following code
      <umbraco:Macro DocTypeAlias="Location" LocationPropAlias="coordinates" 
          UnitInMiles="1" NumberOfResults="500" Alias="Locator" 
          runat="server"></umbraco:Macro>
    Up to this point, when navigating to my page, which is formed similar to the following, I get the text "Please provide a search term" output where I placed the macro: http://www.mywebsite.net/about/branchesoffices/
    Then I tried a few of the following querystrings... none seemed to work. All got the error "input string was not in the correct format"
    What is s supposed to be?
    Many thanks!
  • Mike Joseph 9 posts 29 karma points
    Dec 07, 2011 @ 01:55
    Mike Joseph
    0

    I figured out what was going on for me.

    Some of my coordinates in my Node Collection were not populated and returning a

    I simploy put an if statement in the foreach to account for this:

    foreach (var node in nodesToSearchThrough{

              string coordinates node.GetProperty(locationPropAlias).Value;
        
              if (coordinates != "")
              {
                Location itemLocation new Location(
                  Convert.ToDouble(coordinates.Split(',')[0]Utility.NumberFormatInfo),
                  Convert.ToDouble(coordinates.Split(',')[1]Utility.NumberFormatInfo));
        
                items.Add(new GeoItem(nodeitemLocationsearchLocation.DistanceBetween(itemLocationdistanceunit)));
              }
            }

    Now the following url will work on my site: http://www.mywebsite.net/about/branchesoffices/?s=21801

    Hoping this might help someone else too.

  • Dallas 131 posts 403 karma points
    Jan 22, 2012 @ 19:48
    Dallas
    0

    I have installed the Locator package Razor edition and was not getting any results. Looking at the trace revealed a similar error to the one @Mike was getting

    input string was not in the correct format

    The error is occurring at line 48 where a Location object is created with the property's coordinates

    Location itemLocation = new Location(
    Convert.ToDouble(node.GetProperty(locationPropAlias).ToString().Split(',')[0], Utility.NumberFormatInfo),
            Convert.ToDouble(node.GetProperty(locationPropAlias).ToString().Split(',')[1], Utility.NumberFormatInfo));

     

    node.GetProperty(locationPropAlias).ToString() doesn't return the value of the property but the name of the property Type. So ToDouble throws a formatting error because it is not getting a number.
    It will work if you change it use the value property
    node.GetProperty(locationPropAlias).Value
     

     

  • Kalle Ekstrand 181 posts 259 karma points c-trib
    Mar 21, 2012 @ 10:21
    Kalle Ekstrand
    0

    i have the same problem, any ideas?

  • Dallas 131 posts 403 karma points
    Mar 21, 2012 @ 13:21
    Dallas
    0

    Hi Kalle

    I think it will work if you change it to this

     

     

    Location itemLocation =newLocation(
    Convert.ToDouble(node.GetProperty(locationPropAlias).Value.Split(',')[0],Utility.NumberFormatInfo),
           
    Convert.ToDouble(node.GetProperty(locationPropAlias).Value.Split(',')[1],Utility.NumberFormatInfo));

     

     


  • James 4 posts 24 karma points
    May 01, 2012 @ 13:24
    James
    0

    Hi,

    I've been having the 

    Error loading Razor Script Locator.cshtml

    Cannot perform runtime binding on a null reference

    problem and been working on it for the last day or so, finally solved the problem.

    I had already created a load of Distributors under List of Distributors before I started playing around with the Locator and Google Maps packages, so I only set two of the distributors with Google Map coordinates. I kept on getting the error message until I filled in all the rest of the Distributors with test Google Maps coordinates and republished them all. If you add any new Distributors, the problem doesnt return...which is nice.

    Hope this saves someone a bit of time!

    Peace out! 

  • Daniel.S 50 posts 135 karma points
    Aug 07, 2012 @ 09:11
    Daniel.S
    0

    In my case, I've already got a heap of content that has locations stored using Darren Ferguson's Google Maps datatype. When I tried using this package, I got the error:

    Error Loading Razor Script (file: Locator) Input string was not in a correct format.    at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
      at System.Double.Parse(String s, NumberStyles style, IFormatProvider provider)
      at CallSite.Target(Closure , CallSite , Type , Object , NumberFormatInfo )
      at ASP._Page_macroScripts_Locator_cshtml.Execute() in c:\inetpub\blah.local\macroScripts\Locator.cshtml:line 48

    I modified lines 42,43 & 44 of locator.cshtml to be:

                  Location itemLocation new Location(
                        Convert.ToDouble(node.GetProperty(locationPropAlias).Value.ToString().Split(',')[0]Utility.NumberFormatInfo),
                        Convert.ToDouble(node.GetProperty(locationPropAlias).Value.ToString().Split(',')[1]Utility.NumberFormatInfo))

    instead of:

                  Location itemLocation new Location(
                        Convert.ToDouble(node.GetProperty(locationPropAlias).ToString().Split(',')[0]Utility.NumberFormatInfo),
                        Convert.ToDouble(node.GetProperty(locationPropAlias).ToString().Split(',')[1]Utility.NumberFormatInfo))

    Note the Value.ToString()

    It then worked perfectly. Thanks for a great package. Saved me a lot of time and mucking around.

  • Yik Tan 6 posts 26 karma points
    Oct 10, 2012 @ 12:51
    Yik Tan
    0

    Hi, im trying to use this package but having problem to set it up. The website http://www.nibble.be/?p=105 does not give enough instruction to set it up. I have no idea of where to store the long/late

     

    Please Help

  • mithun 42 posts 63 karma points
    Mar 12, 2013 @ 15:55
    mithun
    0

    Hi,

    I tried  all the method bit still value not getting.please help below are the codes.

     foreach (var node in nodesToSearchThrough{
                  
                     
                                                        
                   Location itemLocation new Location(
                        Convert.ToDouble(node.GetProperty(locationPropAlias).Value.ToString().Split(',')[0]Utility.NumberFormatInfo),
                        Convert.ToDouble(node.GetProperty(locationPropAlias).Value.ToString().Split(',')[1]Utility.NumberFormatInfo));  
                        
                  items.Add(new GeoItem(node,itemLocation,searchLocation.DistanceBetween(itemLocation,distanceunit)));                                 
                                                        
                                         
                  still shows item count = 0 so no value displaying

    regards

    mithun
                             

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Mar 12, 2013 @ 16:24
    Tim Geyssens
    0

    Think the code needs an update will check

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Mar 12, 2013 @ 16:34
    Tim Geyssens
    0

    Well you need to provide a search by adding ?s=[location that I want to search for] to your querystring but that then ends up in 

    Error loading MacroEngine script (file: Locator.cshtml)

    Looking into it

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Mar 12, 2013 @ 16:39
    Tim Geyssens
    0

    Of in the Locator.cshtml scripting file 

    look for this code

     Location itemLocation = new Location(

                        Convert.ToDouble(node.GetProperty(locationPropAlias).ToString().Split(',')[0], Utility.NumberFormatInfo),

                        Convert.ToDouble(node.GetProperty(locationPropAlias).ToString().Split(',')[1], Utility.NumberFormatInfo)); 

    and change to

     Location itemLocation = new Location(

                        Convert.ToDouble(node.GetProperty(locationPropAlias).Value.ToString().Split(',')[0], Utility.NumberFormatInfo),

                        Convert.ToDouble(node.GetProperty(locationPropAlias).Value.ToString().Split(',')[1], Utility.NumberFormatInfo)); 

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Mar 12, 2013 @ 17:15
    Tim Geyssens
    0

    this is a version that tries to fetch the current user position:

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using Locator
    @using Locator.GeoCoding
    @using Locator.GeoCoding.Services.Google
    @using umbraco.MacroEngines;
    
    @{
    
       @* Select the nodes you want to search through, defaults to children *@
       var nodesToSearchThrough = string.IsNullOrEmpty(Parameter.DocTypeAlias) ?
                Model.Children.Where("Visible"): Model.AncestorOrSelf(1).Descendants(Parameter.DocTypeAlias).Where("Visible");
    
       @* Alias of the property containing the long/lat, defaults to location *@
       string locationPropAlias = string.IsNullOrEmpty(Parameter.LocationPropAlias) ? "location" : Parameter.locationPropAlias;
    
       @* Number of results, defaults to 5 *@
       int numberOfSearchResults = string.IsNullOrEmpty(Parameter.NumberOfResults)|| Parameter.NumberOfResults == "0" ? 5 : int.Parse(Parameter.NumberOfResults);
    
       @* Distance unit, defaults to km *@
       DistanceUnits distanceunit = Parameter.UnitInMiles == "1" ? DistanceUnits.Miles : DistanceUnits.Kilometers;
    
    
       List<GeoItem> items = new List<GeoItem>();
       Location searchLocation = new Location();
    
       if(string.IsNullOrEmpty(Request["s"]))
       {
           @* Search term not provided *@ 
    
    
           <div id="location-search">         
           <p>Unable to fetch current location, please use search box</p>
           <form action="@Model.Url">
                <input name="s" type="text" placeholder="Enter the location"/>
                <input type="submit" value="Search" />
           </form>
           </div>
    
           <text>
               <script>
                 document.getElementById("location-search").style.display = 'none';
    
                if (navigator.geolocation) {
                    navigator.geolocation.getCurrentPosition(geoSuccess, geoError);
                }else
                {
                    document.getElementById("location-search").style.display = 'block';
                }
    
                function geoSuccess(position) {
                    window.location = "@Model.Url?s=" + position.coords.latitude + "," + position.coords.longitude;
                }
                function geoError(error)
                {
                     document.getElementById("location-search").style.display = 'block';
                }
                </script>
           </text>           
    
       }
       else 
       {
          @* Lookup search location coordinates *@ 
          GeoResponse r = GoogleGeoCoder.CallGeoWS(Request["s"]);
    
          if(r.Results.Length == 0)
          {
            @* Location not found *@ 
            <p>Location not found:  @Request["s"]</p>
          }
          else
          {
            @* build up list of results *@       
            searchLocation = new Location(r.Results[0].Geometry.Location.Lat, r.Results[0].Geometry.Location.Lng);
    
            foreach (var node in nodesToSearchThrough) {
    
                  Location itemLocation = new Location(
                        Convert.ToDouble(node.GetProperty(locationPropAlias).Value.ToString().Split(',')[0], Utility.NumberFormatInfo),
                        Convert.ToDouble(node.GetProperty(locationPropAlias).Value.ToString().Split(',')[1], Utility.NumberFormatInfo));  
    
                  items.Add(new GeoItem(node,itemLocation,searchLocation.DistanceBetween(itemLocation,distanceunit)));
    
    
    
            }
            @* sort based on distance *@
            items.Sort(new GeoItemComparer());
    
          }
       }
    }
    @if(items.Count > 0)
    {
    @* Output Results *@ 
    
    <p>Result for: @Request["s"]</p>
    
    @* Output Map *@
    
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
    </script>
    
    <div id="map_canvas" style="width:500px; height:500px"></div>
    
    <script type="text/javascript">
      function initialize() {
        var latlng = new google.maps.LatLng(
                        @searchLocation.Latitude.ToString(Utility.NumberFormatInfo), 
                        @searchLocation.Longitude.ToString(Utility.NumberFormatInfo));
        var myOptions = {
          zoom: 8,
          center: latlng,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"),
            myOptions);
        @{int c = 1;}                      
        @foreach(GeoItem geo in items.Take(numberOfSearchResults)){
            dynamic node = ((DynamicNode)geo.Node);    
    
            <text>
              var mLatlng@(c) = new google.maps.LatLng(
                                          @geo.Location.Latitude.ToString(Utility.NumberFormatInfo),
                                          @geo.Location.Longitude.ToString(Utility.NumberFormatInfo));
              var marker@(c) = new google.maps.Marker({
                  position: mLatlng@(c) , 
                  map: map, 
                  title:"@node.Name"
              });                                                              
             </text>
            c++;                                                  
       }
      }
      initialize();
    </script>
    
    
    @* Output list *@
    <ul>
    @foreach(GeoItem geo in items.Take(numberOfSearchResults)){ 
      dynamic node = ((DynamicNode)geo.Node);                                                
      <li><a href="@node.Url">@node.Name - @geo.Distance.ToString("0.00") km</a></li>                               
    }
    </ul>
    }
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies