ThinkGeo.com    |     Documentation    |     Premium Support

Buffer Error On AdvancedGeoCode Function

Hi,


I have downloaded latest "Map Suite Geocode USA Full Edition 2.1" and using the application downloaed with this Edition i was trying to get Latituide and longitude for a given address.


Here is My code:


 private GeoCodeEngine geoEngine;



        private GeoCodeUSASettings geoCodeUSASettings = GeoCodeDesktopCSSample.CSApplication.GetSettingsFromXML();



        protected void Page_Load(object sender, EventArgs e)

        {

            if (!IsPostBack)

            {

                geoEngine = new GeoCodeEngine(@"C:\Program Files\ThinkGeo\Map Suite Geocode USA Full Edition 2.1\GeoCodeIndex", false);

                GeoCodeResult geoCodeResult =new GeoCodeResult();

                geoCodeResult = geoEngine.AdvancedGeoCode("1617 St. Andrews Dr.", "Lawrence", "KS", "66047", ref geoCodeUSASettings);

                DisplayResults(ref geoCodeResult);

                

                Map1.MapUnit = GeographyUnit.DecimalDegree;



                PointShape Pp = new PointShape();

                Pp.X = Convert.ToDouble(geoCodeResult.Latitude);

                Pp.Y = Convert.ToDouble(geoCodeResult.Longitude);



                Map1.MarkerOverlay.Features.Clear();

                Map1.MarkerOverlay.Features.Add("marker", new Feature(Pp));



                Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#B3C6D4"));

                Map1.CurrentExtent = new RectangleShape(-131.22, 55.05, -54.03, 16.91);

                Map1.MapUnit = GeographyUnit.DecimalDegree;



                //Map1.CurrentExtent = new RectangleShape(-97.7458275477605, 30.2976947428081, -97.728208518133, 30.2851233270739);



                Map1.CurrentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);



                ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Evaluation Edition 3.0\Samples\VB Samples\SampleData\World\cntry02.shp");

                worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(255, 243, 239, 228), GeoColor.FromArgb(255, 218, 193, 163), 1);

                worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;



                ShapeFileFeatureLayer citiesLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Evaluation Edition 3.0\Samples\VB Samples\SampleData\USA\cities_a.shp");

                citiesLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City3;

                citiesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                citiesLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = new TextStyle("AREANAME", new GeoFont("Verdana", 9), new GeoSolidBrush(GeoColor.StandardColors.Black));

                citiesLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen = new GeoPen(GeoColor.StandardColors.White, 2);

                citiesLayer.DrawingMarginPercentage = 50;



                ShapeFileFeatureLayer streetLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Evaluation Edition 3.0\Samples\VB Samples\SampleData\USA\Austin\austinstreets.shp");

                streetLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad2;

                streetLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                streetLayer.DrawingMarginPercentage = 80;

               





                LayerOverlay layerOverlay = new LayerOverlay("ThinkGeoMap");

                Map1.StaticOverlay.Layers.Add("WorldLayer", worldLayer);

                Map1.StaticOverlay.Layers.Add("CitiesLayer", citiesLayer);

                Map1.StaticOverlay.Layers.Add("Austin", streetLayer);



                Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;



            }

        }


At line       geoCodeResult = geoEngine.AdvancedGeoCode("1617 St. Andrews Dr.", "Lawrence", "KS", "66047", ref geoCodeUSASettings);


it is giving the following error 


The output char  buffer is too small to contain the decoded characters, encoding 'Unicode  (UTF-8)' fallback 'System.Text.DecoderReplacementFallback'. Parameter name:  chars 


I have used the same CSApplication.cs file as used in Downloaded application to set setting for GeoCodeUSASettings


Please help on this problem and please review my code if i m following thre right way to get Address on map via getting latitude and longitude for a given address


Thanks for your immediate reply


Anil Dutt


 



Anil, 
  
   I have never run across this error before.  What is the region setting for your version of Windows?  Are you running in a foreign country?  I am not sure if this has anything to do with it but I am curious.  I will try and track this down and this information would be helpful when trying to re-produce the error. 
  
 David

David- he is definitely running the program in India- that is where his office is.   
  


Hi David- I am online, you can find me under "Ian Silverthorne" on Microsoft messenger- please post how we can communicate with you.

Hi David,


Last week with your help i m able to render map using following code


 geoEngine = New GeoCodeEngine("C:\Program Files\ThinkGeo\Map Suite Geocode USA Full Edition 2.1\GeoCodeIndex", False)Dim geoCodeResult As New GeoCodeResult()"ALABAMA Street", "WHITE CLOUD", "KS", "66094", geoCodeUSASettings)Dim Pp As New PointShape()New GeoSolidBrush(GeoColor.FromHtml("#B3C6D4"))New RectangleShape(-97.7458275477605, 30.2976947428081, -97.728208518133, 30.2851233270739)Dim worldLayer As New ShapeFileFeatureLayer("C:\Program Files\ThinkGeo\Map Suite Web Evaluation Edition 3.0\Samples\VB Samples\SampleData\World\cntry02.shp")Dim citiesLayer As New ShapeFileFeatureLayer("C:\Program Files\ThinkGeo\Map Suite Web Evaluation Edition 3.0\Samples\VB Samples\SampleData\USA\cities_a.shp")New TextStyle("AREANAME", New GeoFont("Verdana", 9), New GeoSolidBrush(GeoColor.StandardColors.Black))New GeoPen(GeoColor.StandardColors.White, 2)Dim streetLayer As New ShapeFileFeatureLayer("C:\Program Files\ThinkGeo\Map Suite Web Evaluation Edition 3.0\Samples\VB Samples\SampleData\USA\Austin\austinstreets.shp")"WorldLayer", worldLayer)"CitiesLayer", citiesLayer)"StreetLayer", streetLayer)"mymarker", New Feature(Pp))

The above code display only city on the map, i want to display particlular street of the address.


For this i have added streetLayer but it is not showing on the map.  Please tell me how to show proper addres on the map as one showing on you online demo map at onlinedemos.thinkgeo.com/geocodeusa/Default.aspx . I want to show same map as on demo.  


Please see the attached image, how my maps render.


Thanks for your immediate reply.                                                                                                                                                                                                   


 


 



 


geoCodeResult = geoEngine.AdvancedGeoCode(


 


Pp.X = Convert.ToDouble(geoCodeResult.Longitude)


Pp.Y = Convert.ToDouble(geoCodeResult.Latitude)


Map1.MapUnit = GeographyUnit.DecimalDegree


Map1.MapBackground.BackgroundBrush =


Map1.CurrentExtent =


 


worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(255, 243, 239, 228), GeoColor.FromArgb(255, 218, 193, 163), 1)


worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20


 


citiesLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City3


citiesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20


citiesLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle =


citiesLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen =


citiesLayer.DrawingMarginPercentage = 50


 


streetLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad2


streetLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20


streetLayer.DrawingMarginPercentage = 80


Map1.StaticOverlay.Layers.Add(


Map1.StaticOverlay.Layers.Add(


Map1.StaticOverlay.Layers.Add(


Map1.MarkerOverlay.Features.Add(


Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20



 Posted By Anil on 02-03-2009 04:17 AM 

Hi David,


Last week with your help i m able to render map using following code


  geoEngine = New GeoCodeEngine(“C:\Program Files\ThinkGeo\Map Suite Geocode USA Full Edition 2.1\GeoCodeIndex”, False)

        Dim geoCodeResult As New GeoCodeResult()

        geoCodeResult = geoEngine.AdvancedGeoCode(“ALABAMA Street”, “WHITE CLOUD”, “KS”, “66094”, geoCodeUSASettings)



        Dim Pp As New PointShape()

        Pp.X = Convert.ToDouble(geoCodeResult.Longitude)

        Pp.Y = Convert.ToDouble(geoCodeResult.Latitude)



        Map1.MapUnit = GeographyUnit.DecimalDegree

        Map1.MapBackground.BackgroundBrush = New GeoSolidBrush(GeoColor.FromHtml("#B3C6D4"))



        Map1.CurrentExtent = New RectangleShape(-97.7458275477605, 30.2976947428081, -97.728208518133, 30.2851233270739)



        Dim worldLayer As New ShapeFileFeatureLayer(“C:\Program Files\ThinkGeo\Map Suite Web Evaluation Edition 3.0\Samples\VB Samples\SampleData\World\cntry02.shp”)

        worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(255, 243, 239, 228), GeoColor.FromArgb(255, 218, 193, 163), 1)

        worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20



        Dim citiesLayer As New ShapeFileFeatureLayer(“C:\Program Files\ThinkGeo\Map Suite Web Evaluation Edition 3.0\Samples\VB Samples\SampleData\USA\cities_a.shp”)

        citiesLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City3

        citiesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20

        citiesLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = New TextStyle(“AREANAME”, New GeoFont(“Verdana”, 9), New GeoSolidBrush(GeoColor.StandardColors.Black))

        citiesLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen = New GeoPen(GeoColor.StandardColors.White, 2)

        citiesLayer.DrawingMarginPercentage = 50



        Dim streetLayer As New ShapeFileFeatureLayer(“C:\Program Files\ThinkGeo\Map Suite Web Evaluation Edition 3.0\Samples\VB Samples\SampleData\USA\Austin\austinstreets.shp”)

        streetLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad2

        streetLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20

        streetLayer.DrawingMarginPercentage = 80



        Map1.StaticOverlay.Layers.Add(“WorldLayer”, worldLayer)

        Map1.StaticOverlay.Layers.Add(“CitiesLayer”, citiesLayer)

        Map1.StaticOverlay.Layers.Add(“StreetLayer”, streetLayer)



        Map1.MarkerOverlay.Features.Add(“mymarker”, New Feature(Pp))

        Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20


The above code display only city on the map, i want to display particlular street of the address.


For this i have added streetLayer but it is not showing on the map.  Please tell me how to show proper addres on the map as one showing on you online demo map at onlinedemos.thinkgeo.com/geocodeusa/Default.aspx . I want to show same map as on demo.  


Please see the attached image, how my map render.


Thanks for your immediate reply.                                                                                                                                                                                                   


 




Anil,


I will answer this on behalf of David.


First, seems you have difficulties posting codes. Please check the thread here which can help you post nice codes


gis.thinkgeo.com/Support/Dis...fault.aspx


Here is the sample for your requirement, labels will be shown up when mouse is over the marker.



Let me know for more queries.


Ben.



355-GeocodeUSAVB.zip (5.96 KB)

Hi Ben,


Thanks for your reply.


But when i tried to download the attachment its giving me following error


XML Parsing Error: no element found



Location:


gis.thinkgeo.com/DesktopModules/ActiveForums/viewer.aspx?portalid=1&moduleid=623&attachid=355

Line Number 1, Column 1:



 Thanks,                                                                                                                                                                                                                       Anil Dutt



Hi David


Now, i get the Download attahment file by Ian.


When i run a Project i get the Error of some  missing dll like   WebEdition.DLL and MapSuiteCore.dll . then  i used the dll which i already have "WebEdition.dll" and also add the "MapSuiteCore.dll","GeoCodeUSA.dll".


After that when i run a solution get the Error on the following line.


 


getting error in below line in Page_Load function


rangeLayer.InternalFeatures.Add(New Feature(Pp))


Error 6 Argument not specified for parameter 'value' of 'Public Sub Add(key As TKey, value As TValue)'. D:\Projects\Thinkgeo\GeocodeUSAVB1\GeocodeUSAVB1\GeocodeUSAVB\Default.aspx.vb 43 13 D:\...\GeocodeUSAVB\


Map1.CenterAt(Pp)


Error 9 'CenterAt' is not a member of 'ThinkGeo.MapSuite.WebEdition.Map'.D:\Projects\Thinkgeo\GeocodeUSAVB1\GeocodeUSAVB1\GeocodeUSAVB\Default.aspx.vb  53 13 D:\...\GeocodeUSAVB\


 


Getting a following error in the line in function RenderRangedMarker


 


rangeLayer.InternalFeatures.Add(New Feature(Pp))


Error  10  Argument not specified for parameter 'value' of 'Public Sub Add(key As TKey, value As TValue)'.  D:\Projects\Thinkgeo\GeocodeUSAVB1\GeocodeUSAVB1\GeocodeUSAVB\Default.aspx.vb 156 9 D:\...\GeocodeUSAVB\


Error 11 Value of type 'ThinkGeo.MapSuite.Core.Feature' cannot be converted to 'String'. D:\Projects\Thinkgeo\GeocodeUSAVB1\GeocodeUSAVB1\GeocodeUSAVB\Default.aspx.vb 156 41 D:\...\GeocodeUSAVB\


Map1.MarkerOverlay.Features.Add(markerFeature)


 


Error 12 Argument not specified for parameter 'value' of 'Public Sub Add(key As TKey, value As TValue)'. D:\Projects\Thinkgeo\GeocodeUSAVB1\GeocodeUSAVB1\GeocodeUSAVB\Default.aspx.vb 177 13 D:\...\GeocodeUSAVB\


Error 13 Value of type 'ThinkGeo.MapSuite.Core.Feature' cannot be converted to 'String'. D:\Projects\Thinkgeo\GeocodeUSAVB1\GeocodeUSAVB1\GeocodeUSAVB\Default.aspx.vb  177 45 D:\...\GeocodeUSAVB\


rangeLayer.InternalFeatures.Add(New Feature(range))


Error 14 Argument not specified for parameter 'value' of 'Public Sub Add(key As TKey, value As TValue)'. D:\Projects\Thinkgeo\GeocodeUSAVB1\GeocodeUSAVB1\GeocodeUSAVB\Default.aspx.vb 180 9 D:\...\GeocodeUSAVB\


Error 15 Value of type 'ThinkGeo.MapSuite.Core.Feature' cannot be converted to 'String'. D:\Projects\Thinkgeo\GeocodeUSAVB1\GeocodeUSAVB1\GeocodeUSAVB\Default.aspx.vb 180 41 D:\...\GeocodeUSAVB\


 


Please help me on these error............


Thanks for your immediate reply.............


 


 


 


 


 



Anil, 
  
 Seems you are using an very old version of Web Edition.  Can you update your assemblies to the latest one (3.1.4) or can you wait for the new release which will be available tomorrow or this Monday. 
  
 Btw, can you let me know what browser you are using, just wondering why you cannot get that attachement. 
  
 Thanks, 
  
 Ben

Hi Ben


I download a latest version of  from link   "download.thinkgeo.com/MapSuiteWebEvalSetup.zip"


but in this i am getting  "WebEdition.dll"   and the   version  of dll is 3.0.131.0 .


Can you tell the link  from  where i get the latest version of your assembly?.


by the way i am using a Firfiox  version 3.0.6. fro downloading your attachment


Thanks


Anil


 


 


 



Hi Ben


i get the latest verson of DLL 3.1.4. and error is remove but.


it not showing a map. as show in your previous post.


please see the attachment.


appricate any help


Thanks


 


 


 


 


 



Anil, 
  
 I downloaded the attached demo (I posted on Feb 5th ), tried it with 3.1.4 and 3.1.16(latest version) and it both works fine.  Can you download the latest 3.1.16 one and have another try? You can easily get if from our webpage. (Login with your account) 
  
 Also, I didn’t see any attachment in you last message; did you forget to attach that? 
  
 Thanks, 
  
 Ben 


Hello,


I am looking into Map generation problem and tried following code which is working fine with "Austin, Texas" address but what I should change to make it working for other states like "Kansas". I am using following components


1. Map Suite Web Evaluation Edition 3.0


2. Map Suite GeoCode USA Full Editon 2.1


3. Map Suite World Map Kit


Do you have any documentation about product which can give information about all classes, functions etc? 


In the following example I am using this MapPath("app_data/usa/austin/austinstreets.shp")


can you please tell me will you provide these shp files for all states?


Thanks


Following is the code (save it as Default.aspx)


Imports Microsoft.VisualBasic

Imports System

Imports System.Collections.ObjectModel

Imports ThinkGeo.MapSuite.Core

Imports ThinkGeo.MapSuite.WebEdition

Imports MapSuite.GeoCodeUSA

Imports System.Xml



Partial Class _Default

    Inherits System.Web.UI.Page

    Private geoEngine As GeoCodeEngine

    Private geoCodeUSASettings As GeoCodeUSASettings



    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

        If Not Page.IsPostBack Then

            geoEngine = New GeoCodeEngine("D:\GeocodeUSA2.1\Geocode USA 2.1\GeocodeIdx", False)

            Dim geoCodeResult As New GeoCodeResult()

            geoCodeUSASettings = GetSettingsFromXML()

            geoCodeResult = geoEngine.AdvancedGeoCode("107 W 6th St.", "Austin", "TX", "78701", geoCodeUSASettings)

            Dim Pp As New PointShape()

            Pp.X = Convert.ToDouble(geoCodeResult.Longitude)

            Pp.Y = Convert.ToDouble(geoCodeResult.Latitude)

            ViewState("Pp") = Pp



            Map1.MapUnit = GeographyUnit.DecimalDegree

            Map1.CurrentExtent = New RectangleShape(-97.74919, 30.27317, -97.73661, 30.26292)



            Dim streetLayer As New ShapeFileFeatureLayer(MapPath("app_data/usa/austin/austinstreets.shp"))

            streetLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad2

            streetLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20

            streetLayer.DrawingMarginPercentage = 80



            Dim streetTxLayer As New ShapeFileFeatureLayer(MapPath("app_data/usa/austin/austinstreets.shp"))

            streetTxLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.Highway5("FENAME")

            streetTxLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20

            streetTxLayer.DrawingMarginPercentage = 80



            Dim rangeLayer As New InMemoryFeatureLayer()

            rangeLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.Red, 20)

            rangeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(100, 200, 255, 200)

            rangeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.LightGreen

            rangeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20

            rangeLayer.InternalFeatures.Add(New Feature(Pp))



            Map1.StaticOverlay.Layers.Add("StreetLayer", streetLayer)

            Map1.StaticOverlay.Layers.Add("StreetTxLayer", streetTxLayer)

            Map1.DynamicOverlay.Layers.Add("RangeLayer", rangeLayer)



            Map1.MarkerOverlay.Columns.Add(New FeatureSourceColumn("FENAME"))

            Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20



            Map1.CenterAt(Pp)

        End If

    End Sub



    Private Function GetCloudPopup(ByVal position As PointShape, ByVal contentHtml As String) As CloudPopup

        Dim popup As CloudPopup = New CloudPopup()

        popup.ContentHtml = String.Format("{0}", contentHtml)

        popup.AutoSize = True

        popup.Position = position

        Return popup

    End Function



    Public Function GetSettingsFromXML() As GeoCodeUSASettings

        ' If not exists then create the setting XML file

        If Not System.IO.File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location) & "\Settings.xml") Then

            CreateSettingsXml()

        End If

        Try

            Dim geoCodeSettings As New GeoCodeUSASettings

            Dim settings As New Xml.XmlDocument

            settings.Load(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location) & "\Settings.xml")

            geoCodeSettings.ClosestStreetNumber = CBool(settings.SelectSingleNode("//ClosestStreetNumber").InnerText)

            geoCodeSettings.ExactMatch = CBool(settings.SelectSingleNode("//ExactMatch").InnerText)

            geoCodeSettings.FuzzyStreetName = CBool(settings.SelectSingleNode("//FuzzyStreetName").InnerText)

            geoCodeSettings.IgnoreDirectionals = CBool(settings.SelectSingleNode("//IgnoreStreetDirectionals").InnerText)

            geoCodeSettings.IgnoreStreetType = CBool(settings.SelectSingleNode("//IgnoreStreetType").InnerText)

            geoCodeSettings.NearbyZip = CBool(settings.SelectSingleNode("//CheckNearByZipCodes").InnerText)

            geoCodeSettings.ZipCentroid = CBool(settings.SelectSingleNode("//ZipCentroid").InnerText)

            settings = Nothing

            Return geoCodeSettings

        Catch ex As Exception

            Throw ex

        End Try

    End Function



    Public Sub CreateSettingsXml()

        Dim doc As New XmlDocument()

        Dim node As XmlNode

        node = doc.CreateXmlDeclaration("1.0", "utf-8", "")

        doc.AppendChild(node)

        node = doc.CreateElement("GeoCodeUSASettings")

        doc.AppendChild(node)

        node = doc.CreateElement("ExactMatch")

        doc.DocumentElement.AppendChild(node)

        node = doc.CreateElement("ClosestStreetNumber")

        doc.DocumentElement.AppendChild(node)

        node = doc.CreateElement("FuzzyStreetName")

        doc.DocumentElement.AppendChild(node)

        node = doc.CreateElement("IgnoreStreetType")

        doc.DocumentElement.AppendChild(node)

        node = doc.CreateElement("IgnoreStreetDirectionals")

        doc.DocumentElement.AppendChild(node)

        node = doc.CreateElement("CheckNearByZipCodes")

        doc.DocumentElement.AppendChild(node)

        node = doc.CreateElement("ZipCentroid")

        doc.DocumentElement.AppendChild(node)

        doc.Save(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Settings.xml")

        Dim GeoCodeUSASettings As New GeoCodeUSASettings

        GeoCodeUSASettings.ExactMatch = False

        GeoCodeUSASettings.IgnoreStreetType = True

        GeoCodeUSASettings.IgnoreDirectionals = True

        GeoCodeUSASettings.ZipCentroid = False

        GeoCodeUSASettings.NearbyZip = False

        GeoCodeUSASettings.ClosestStreetNumber = True

        GeoCodeUSASettings.FuzzyStreetName = True

        WriteSettingsToXML(GeoCodeUSASettings)

    End Sub



    Public Sub WriteSettingsToXML(ByRef GeoCodeSettings As GeoCodeUSASettings)

        Try

            Dim settings As New Xml.XmlDocument

            Dim path As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location) & "\Settings.xml"

            settings.Load(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location) & "\Settings.xml")

            settings.SelectSingleNode("//ClosestStreetNumber").InnerText = IIf(GeoCodeSettings.ClosestStreetNumber, 1, 0)

            settings.SelectSingleNode("//ExactMatch").InnerText = IIf(GeoCodeSettings.ExactMatch, 1, 0)

            settings.SelectSingleNode("//FuzzyStreetName").InnerText = IIf(GeoCodeSettings.FuzzyStreetName, 1, 0)

            settings.SelectSingleNode("//IgnoreStreetDirectionals").InnerText = IIf(GeoCodeSettings.IgnoreDirectionals, 1, 0)

            settings.SelectSingleNode("//IgnoreStreetType").InnerText = IIf(GeoCodeSettings.IgnoreStreetType, 1, 0)

            settings.SelectSingleNode("//CheckNearByZipCodes").InnerText = IIf(GeoCodeSettings.NearbyZip, 1, 0)

            settings.SelectSingleNode("//ZipCentroid").InnerText = IIf(GeoCodeSettings.ZipCentroid, 1, 0)

            settings.Save(path)

            settings = Nothing

        Catch ex As Exception

            Throw ex

        End Try

    End Sub



    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        RenderRangedMarker(1000)

    End Sub



    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

        RenderRangedMarker(1500)

    End Sub



    Private Sub RenderRangedMarker(ByVal distance As Double)

        Dim Pp As PointShape = CType(ViewState("Pp"), PointShape)

        Dim range As MultipolygonShape = Pp.Buffer(distance, 40, GeographyUnit.DecimalDegree, DistanceUnit.Feet)

        Dim streetLayer As ShapeFileFeatureLayer = CType(Map1.StaticOverlay.Layers("StreetLayer"), ShapeFileFeatureLayer)

        Dim rangeLayer As InMemoryFeatureLayer = CType(Map1.DynamicOverlay.Layers("RangeLayer"), InMemoryFeatureLayer)



        rangeLayer.InternalFeatures.Clear()

        rangeLayer.InternalFeatures.Add(New Feature(Pp))



        streetLayer.Open()

        Dim streetsFeature As Collection(Of Feature) = streetLayer.QueryTools.GetFeaturesWithin(range, ReturningColumnsType.AllColumns)

        streetLayer.Close()



        Map1.MarkerOverlay.Features.Clear()

        Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.ContentHtml = "[#FENAME#]"

        Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.BackgroundColor = GeoColor.FromHtml("#FFFFCC")

        Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.BorderWidth = 1

        Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.BorderColor = GeoColor.FromHtml("#0000cc")

        Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.AutoSize = True

        Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageWidth = 21

        Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageHeight = 25

        Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageOffsetX = -10.5F

        Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageOffsetY = -25.0F



        For Each feature As Feature In streetsFeature

            Dim address As String = feature.ColumnValues("FENAME")

            Dim markerFeature As New Feature(feature.GetBoundingBox().GetCenterPoint())

            markerFeature.ColumnValues.Add("FENAME", feature.ColumnValues("FENAME"))

            Map1.MarkerOverlay.Features.Add(markerFeature)

        Next



        rangeLayer.InternalFeatures.Add(New Feature(range))

        Map1.DynamicOverlay.Redraw()

    End Sub

End Class

 



Rohit, 


World Map Kit includes all the road files all over the US. GeoCode USA Full Edition supports locating any address in US, so with the components you have got, you can implement the same features as onlinedemos.thinkgeo.com/geocodeusa/Default.aspx  with no problem. Here is how to do it.
 
1, There is a sample alone with the World Map Kit product showing how to use it with Desktop/Web/Service Edition. First, we should make this sample running. Reference the Web component to the web sample project and it should compile and run. It might have some problem that some APIs are renamed in the latest version, (like AreaStyles.GetSimpleAreaStyle has been renamed to AreaStyles.CreateSimpleAreaStyle), you can either change it by yourself (there should not have too many errors as we didn’t changed too many places) or you can get the latest World Map Kit which is compatible with 3.1.x.
 
2, now World Map Kit should be running properly, you will have a world map like what GoogleMap is. Then you need to reference the GeoCode Assembly and integrate it into World Map Kit. Use the following code to locate the point of “107 W 6th St, Austin, TX, 78701”
 

            geoEngine = New GeoCodeEngine("D:\GeocodeUSA2.1\Geocode USA 2.1\GeocodeIdx", False)
            Dim geoCodeResult As New GeoCodeResult()
            geoCodeUSASettings = GetSettingsFromXML()
            geoCodeResult = geoEngine.AdvancedGeoCode("107 W 6th St.", "Austin", "TX", "78701", geoCodeUSASettings)
            Dim Pp As New PointShape()
            Pp.X = Convert.ToDouble(geoCodeResult.Longitude)
            Pp.Y = Convert.ToDouble(geoCodeResult.Latitude) 


And use the following code to center the map to that point.
            Map1.CenterAt(Pp)
 
3, now Geocode has been integrated into the World Map Kit. You can change to another address like “1617 St. Andrews Dr” “Lawrence” “KS” “66047” and see the effects, if you can get here, the point should be located in Lawrence and you can easily make the application similar as onlinedemos.thinkgeo.com/geocodeusa/Default.aspx
 
We have the full documentation for Web Edition along with that product; World Map Kit is an addon class which is very simple and you can easily get it from the provided sample, Geocode is also easy to use as it only has a couple straightforward APIs, sure we provide the documentation along with it which you can check and see.
 
Hope that helps! Let me know if you have any issues.
 
Thanks,
 
Ben

 



Hello Ben, 
  
 Thanks for your efforts for providing more information but most of my questions are still unanswered. Please provide us code which you have deployed at following location and I am sure it will answer all my questions. 
  
 onlinedemos.thinkgeo.com/geocodeusa/Default.aspx.  
  
 Thanks 
 Rohit Kumar 
  


Rohit, 


Here is the sample you want. As many products included in this sample (Web Edition, World Map Kit and Geocode), you need to do some configurations before it is able to run and you need to understand the application codes otherwise you can hardly do any more changes.
 
Here is how to make this sample running.
1, make sure you installed GeocodeUSA2.1.* and Web Edition 3.1.16. Also make sure you got the latest version of World Map Kit (please connect your sales representative for that)
 
2, Make sure the World Map Kit Data (18.7G) and GeoCode data (6G) is ready. Let’s say they are under “D:\WorldMapKit” and “D:\GeoCodeData” relatively.
 
3, Copy the World Map Kit Addon class under the sample’s App_Code folder. The result should be like this.


4, Open the solution with Visual Studio, reference GeoCodeUSA.dll, WebEdition.dll and MapSuiteCore.dll to make it compile.
5, Set the Data folder for both WorldMapKit and Geocode.
            A, go to <appSettings> part (L17) in web.config file, set the value for “WorldMapKitDataFolder” to match your WorldMapKit’s data folder (D:\GeoCodeData for example).
            B, go to L39 of Default.aspx.vb, set the GeoCodeEngine with your GeoCode’s data folder, the code will be like
Dim geoEngine As New GeoCodeEngine("D:\GeoCodeData", False)
 
After that, the application should work fine. When first initialized, it shows all the US, after clicking “GeoCode”, it should be like this

 


Hope it helps, let us know if you have any issues.
 
Thanks,
 
Ben

426-WorldMapKitVBSample.zip (6.11 KB)

Hello Ben, 
  
 Thanks for such a nice help. Its working now finally. You have explained very well. Now we will move further for the concept we want to implement and will post any further query. 
  
 Thanks 
 Rohit Kumar

That’s great, Rohit. Feel free to ask and we are glad to help.

We need to display many locations of a single type on a map.  How do we use a single custom icon to display them all, using the Think Geo program to display the numbers over each icon? 
  
 In other words, if i want to display 35 icons, I would rather not have to create 35 custom individually numbered icons.  Instead, I would like to create one custom icon and let mapsuite number them.