Skip to main content

Microsoft Silverlight

Answered Question Connecting silverlight virtual earth with wcf servicesRSS Feed

(0)

arcobaleno
arcobaleno

Member

Member

3 points

16 Posts

Connecting silverlight virtual earth with wcf services

i am implementing virtual earth in my project. how do i retrieve the longitude and latitude from sql management studio and add pushpin to my project, i read from several websites and it says that i require WCF services. Can any programmer teach me on how do i do it?

varshavmane
varshavmane

Contributor

Contributor

6723 points

1,580 Posts

Answered Question

Re: Connecting silverlight virtual earth with wcf services

Check this:

http://johanneskebeck.spaces.live.com/blog/cns!42E1F70205EC8A96!8528.entry

Hope it helps you.

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

arcobaleno
arcobaleno

Member

Member

3 points

16 Posts

Re: Connecting silverlight virtual earth with wcf services

thanks alot :)
by the way, do you have any C# language source?

varshavmane
varshavmane

Contributor

Contributor

6723 points

1,580 Posts

Re: Connecting silverlight virtual earth with wcf services

I guess its not that difficult Smile

If you have any problem then post it.. we will help you for conversion.

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

arcobaleno
arcobaleno

Member

Member

3 points

16 Posts

Re: Connecting silverlight virtual earth with wcf services

thanks alot for your help. By the way, while i am following the steps of linking to sql database, i encounter a problem while adding service reference which is

 

An error occured while attempting to find services at
'http://localhost:59884/DataService.svc'.

how do i solve this?

varshavmane
varshavmane

Contributor

Contributor

6723 points

1,580 Posts

Re: Re: Connecting silverlight virtual earth with wcf services

Can you please browse the Service ? Is it working fine ?

If you are using any dbml file the make sure that in properties its direction is unidirectional.

One thing you have to check in your Web.Config file, it has your service details you have to make binding="basicHttpBinding" something like this: 

<service behaviorConfiguration="DataServiceBehavior"
        name="DataService">
        <endpoint address=""
          binding="basicHttpBinding" bindingConfiguration="LargeBuffer"
          contract="DataService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>

Or check this link: http://chakkaradeep.wordpress.com/2008/05/31/silverlight-and-wcf/ 

Hope it helps you.

Please let us know if you are still getting the same issue.

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

arcobaleno
arcobaleno

Member

Member

3 points

16 Posts

Re: Re: Connecting silverlight virtual earth with wcf services

while i am using languages converter, i came across this error

 

[OperationContract()]
public List<UK_low_bridges_all> GetPOIinView(double NWlat, double NWlon, double SElat, double SELon)
{
  HannesPOIDataContext datacontext = new HannesPOIDataContext();
  return (().ToList());
}

how do i actually solve it?
sorry to trouble you again.

 

varshavmane
varshavmane

Contributor

Contributor

6723 points

1,580 Posts

Re: Re: Re: Connecting silverlight virtual earth with wcf services

Can you please post the code which you are trying to convert ?

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

arcobaleno
arcobaleno

Member

Member

3 points

16 Posts

Re: Re: Re: Connecting silverlight virtual earth with wcf services

 

Imports System.ServiceModel
Imports System.ServiceModel.Activation

<ServiceContract(Namespace:="DataService")> _
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
Public Class DataService

<OperationContract()> _
Public Function GetPOIinView(ByVal NWlat As Double, _
ByVal NWlon As Double, _
ByVal SElat As Double, _
ByVal SELon As Double) _
As List(Of UK_low_bridges_all)
Dim datacontext As New HannesPOIDataContext
Return ((From UK_low_bridges_alls _
In datacontext.UK_low_bridges_alls _
Where UK_low_bridges_alls.Latitude <= NWlat And _
UK_low_bridges_alls.Latitude >= SElat And _
UK_low_bridges_alls.Longitude >= NWlon And _
UK_low_bridges_alls.Longitude <= SELon).ToList())
End Function

End Class

varshavmane
varshavmane

Contributor

Contributor

6723 points

1,580 Posts

Re: Re: Re: Re: Connecting silverlight virtual earth with wcf services

Try this :

public List<UK_low_bridges_all> GetPOIinView(double NWlat,double NWlon, double SElat, double SELon)

{

HannesPOIDataContext _datacontext =
new HannesPOIDataContext();

var getResult = from UK_low_bridges_alls in _datacontext.UK_low_bridges_alls

where UK_low_bridges_alls.Latitude <= NWlat

&& UK_low_bridges_alls.Latitude >= SElat

&& UK_low_bridges_alls.Longitude >= NWlon

&& UK_low_bridges_alls.Longitude <= SELon;

return getResult.ToList<UK_low_bridges_all>();

}

Hope it helps you ...

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

arcobaleno
arcobaleno

Member

Member

3 points

16 Posts

Re: Re: Re: Re: Connecting silverlight virtual earth with wcf services

i am getting error from this line,

&& UK_low_bridges_alls.Longitude <= SELon;

 Error    2    A query body must end with a select clause or a group clause 
Error    3    The type of the expression in the select clause is incorrect.  Type inference failed in the call to 'Select'.

varshavmane
varshavmane

Contributor

Contributor

6723 points

1,580 Posts

Re: Re: Re: Re: Re: Connecting silverlight virtual earth with wcf services

Sorry I forgot to mention Select Statement in the query:

public List<UK_low_bridges_all> GetPOIinView(double NWlat,double NWlon, double SElat, double SELon)

{

HannesPOIDataContext _datacontext =
new HannesPOIDataContext();

var getResult = from UK_low_bridges_alls in _datacontext.UK_low_bridges_alls

where UK_low_bridges_alls.Latitude <= NWlat

&& UK_low_bridges_alls.Latitude >= SElat

&& UK_low_bridges_alls.Longitude >= NWlon

&& UK_low_bridges_alls.Longitude <= SELon

select UK_low_bridges_alls.ColumnNameWhichYouWant;

return getResult.ToList<UK_low_bridges_all>();

}

where ColumnNameWhichYouWant will be the columns which you want to select just seperate them with comma if you wnat to select more than one column.

Hope it works now .

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

arcobaleno
arcobaleno

Member

Member

3 points

16 Posts

Re: Re: Re: Re: Re: Connecting silverlight virtual earth with wcf services

thanks alot for your help but i am still facing the same Service problem after checking my dbml file properties direction, which is unidirectional and i follow your guide which is to change the binding to 'basicHttpBinding'. is there any steps that i miss out?

varshavmane
varshavmane

Contributor

Contributor

6723 points

1,580 Posts

Re: Re: Re: Re: Re: Re: Connecting silverlight virtual earth with wcf services

Are you able to browse the service something like http://localhost/YoueServiceName.svc ?

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

arcobaleno
arcobaleno

Member

Member

3 points

16 Posts

Re: Re: Re: Re: Re: Re: Connecting silverlight virtual earth with wcf services

can't

varshavmane
varshavmane

Contributor

Contributor

6723 points

1,580 Posts

Re: Re: Re: Re: Re: Re: Re: Connecting silverlight virtual earth with wcf services

If you cant browse http://localhost/YourServiceName.svc then there is some problem with your WCF Service.

Please check whether the Project builds properly ?

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

arcobaleno
arcobaleno

Member

Member

3 points

16 Posts

Re: Re: Re: Re: Re: Re: Re: Connecting silverlight virtual earth with wcf services

i am done with the WCF Service thanks to your help and i am left with last part for the tutorial. i get an error with the Result. The original coding,

Private Sub svc_GetPoiInMapViewCompleted(ByVal sender As Object, _
ByVal e As GetPOIinViewCompletedEventArgs)
If e.Error Is Nothing Then
For
i = 0 To e.Result.Count - 1
Dim point As New Ellipse()
point.Width = 10
point.Height = 10
point.Fill = New SolidColorBrush(Colors.Red)
point.Opacity = 0.65
Dim location As New Location(e.Result(i).Latitude, e.Result(i).Longitude)
MapLayer.SetMapPosition(point, location)
ToolTipService.SetToolTip(point, e.Result(i).Name)

MyPOI.Children.Add(point)
Next
Else
MessageBox.Show("Error occurred while loading POI from database", _
"Error", MessageBoxButton.OK)
End If
End Sub
 
 
my c# coding,
private void svc_GetPoiInMapViewCompleted(object sender, GetPOIinViewCompletedEventArgs e)
{
int i = new int();
if (e.Error == null) {
for (i = 0; i <= e.Result.Count - 1; i++) {
Ellipse point = new Ellipse();
point.Width = 10;
point.Height = 10;
point.Fill = new SolidColorBrush(Colors.Red);
point.Opacity = 0.65;
Location location = new Location(e.Result(i).Latitude, e.Result(i).Longitude);
MapLayer.SetMapPosition(point, location);
ToolTipService.SetToolTip(point, e.Result(i).Name);

MyPOI.Children.Add(point);


}
}
else {
MessageBox.Show("Error occurred while loading POI from database", "Error", MessageBoxButton.OK);
}
 
i get an error from the 'Result', it shows Error	'VE_SL_DBConn.DataServiceReference.GetPOIinViewCompletedEventArgs.Result' cannot be used like a method.	
how do i get it solved? 
 

varshavmane
varshavmane

Contributor

Contributor

6723 points

1,580 Posts

Re: Re: Re: Re: Re: Re: Re: Re: Connecting silverlight virtual earth with wcf services

I guess the problem is with Result(i), you have to change this to ResultIdea.

Hope it helps you Smile

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

arcobaleno
arcobaleno

Member

Member

3 points

16 Posts

Re: Re: Re: Re: Re: Re: Re: Re: Connecting silverlight virtual earth with wcf services

 thanks and i am left with the last error, which lies on

Location location = new Location(e.ResultIdea.Latitude, e.ResultIdea.Longitude);

 

Error    2    The best overloaded method match for 'Microsoft.VirtualEarth.MapControl.Location.Location(double, double)' has some invalid arguments  
Error    3    Argument '1': cannot convert from 'double?' to 'double'   

varshavmane
varshavmane

Contributor

Contributor

6723 points

1,580 Posts

Re: Re: Re: Re: Re: Re: Re: Re: Re: Connecting silverlight virtual earth with wcf services

Just check with the parameters of Location Method. Looks like you are sending some wrong parameters.

Hope it helps you.

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

arcobaleno
arcobaleno

Member

Member

3 points

16 Posts

Re: Re: Re: Re: Re: Re: Re: Re: Re: Connecting silverlight virtual earth with wcf services

 sorry, i am a beginner in programming, i don't fully understand what you mean by the 'location method' in 'parameters of location method'.

varshavmane
varshavmane

Contributor

Contributor

6723 points

1,580 Posts

Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Connecting silverlight virtual earth with wcf services

Can you just try this:

double latitude = e.ResultIdea.Latitude;

double longitude = e.ResultIdea.Longitude;

Location location = new Location(latitude, longitude);

The problem is with Location Method. You have to do like this Location(double, double) but in your code its Location(double? , double).

Hope it helps you Smile

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

arcobaleno
arcobaleno

Member

Member

3 points

16 Posts

Answered Question

Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Connecting silverlight virtual earth with wcf services

sorry, i am still having problem with the 'double' stuffs

                 double latitude = e.ResultIdea.Latitude;

                 double longitude = e.ResultIdea.Longitude;


                 Location location = new Location(latitude, longitude);

 Error    1    Cannot implicitly convert type 'double?' to 'double'. An explicit conversion exists (are you missing a cast?)   

varshavmane
varshavmane

Contributor

Contributor

6723 points

1,580 Posts

Answered Question

Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Connecting silverlight virtual earth with wcf services

Try this: 

double? latitude = e.ResultIdea.Latitude;

double longitude = e.ResultIdea.Longitude;

Location location = new Location(latitude, longitude);

Or

check this link :  http://www.cadmaps.com/gisblog/?p=61

HTH Smile

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities