fredag 13 februari 2015

Open SMIL

Open SMIL is an effort of combining GIS and SharePoint. I build SMIL over 5 years ago. The company I working for using SMIL in various projects and industries. That implies the platform is flexible and customisable. And maybe the most important thing, it addresses change. The users always want another button, more information, authorisation (in my experience rarely used but often asked for of some reason, maybe it is a culture thing?)

However, GIS has a reputation being expensive and complicated. SharePoint provides a highly customisable platform and Bing Maps is a platform with great features covering world wide data. Combining these platforms platform providing a light GIS have been the target of the OpenSMIL project.

OpenSMIL has i mobile map client connected to a SharePoint site, with geo enabled SharePoint lists represented as GIS layers. The mobile client runs in a browser in a SharePoint context. With this tool the user can collect data. The data is stored into a SharePoint list so it is available immediately in SharePoint.

Inside SharePoint there is a WebPart showing the layers (SharePoint lists with geographical information). SharePoint list items are plotted on the map and are clickable.
   

SharePoint lists have two maps, one preview that shows on mouseover an icon in the list.And another showing the item. The user can create new or change geometry. For example draw a polygon that might represent the area for a document.
   

In order to share geographical data with others you can invite them use your SharePoint site or export a list as a KML file. KML is standard See OGC.

But how to enable i list or document library to store geographical information? Easy, just add a column, give it a name and add a new field to the list.

For project place visit, project site. Or jump right into the code.

måndag 6 januari 2014

Extending Bing Maps Pushpin with Attributes

Recently I needed to store attributes with Pushpins in Bing Maps. Either I'm blind or it is just not there. Bing Maps is offering the following properties with the Pushpin object:

If I just try to add a property when initializing the Pushpin, Bing Maps will not take notice of that property due to the setOptions function on the Pushpin object. I don't really want to override the setOptions function - since I don't know the domino effect. So there are still two ways to solve the problem.

  1. Add a property on the Pushpin object - it is Javascript. Such as.
    var pin = new Microsoft.Maps.Pushpin(OpenSMILWebPart.map.getCenter(), { height: 50, width: 50 });
    and just add a property:
    pin.customfield = 'customData';
  2. Add get and set method on the Pushpin object such as:
    Microsoft.Maps.Pushpin.prototype.setAttributes = function () { this._attributes = arguments[0] }; Microsoft.Maps.Pushpin.prototype.getAttributes = function () { return this._attributes; };
    and set properties such as:
    pin.setAttributes({ customObject: 'some data' });
    use get method to receive data:
    pin.getAttributes();
Alternative two is more complex, but more useful if we need to control the data.

Microsoft - feel free to add a Tag property to each geometry type giving the opportunity storing values in.

lördag 28 december 2013

Using Bing services to validate addresses

Bing Maps services provides a feature for geocoding. A way to increase user input address quality, for example in SharePoint, is to present address quality feedback for the user. I've done that with a custom field.
This is the feedback I want to give to the user. I start to structure the application such as:
Why do I use HTTP handlers in SharePoint? In my opiniun they are easier to install than WCF services in SharePoint. But they are low level services. In order to get them to work I have to point out the assembly and the webhandler such as:
<%@ Assembly Name="OpenSMIL.Server, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=deb5cb40dd7862f6" %>
<%@ WebHandler Language="C#" CodeBehind="ValidateAddress.ashx.cs" Class="OpenSMIL.Server.ValidateAddress" %>

After that the server side development is pretty straight forward. As you can see in the image to the left the server code is divided into two seperate parts. The HTTP-handler, wich just needs some codebehind and let the other code worry about the Bing geocoding logic. And that is just a few lines of code.
And the code to ask Bing..

That's all for the services. In order to build a custom field here is a tutorial . And this article can come handy.

I'm almost done, all that is left is a XML-file describing for SharePoint about this field.

What is left now is just some JavaScript for rendering and communicating with the server. I have intentially left out jQuery and other JS libraries since it is basically just an Ajax requests.
That is it. All code is available here.

torsdag 17 oktober 2013

osx eclipse "there are no resources that can be added or removed from the server"

Been struggling with eclipse telling me "there are no resources that can be added or removed from the server". I installed Eclipse Java EE Developer Tools and that got rid of that problem.

onsdag 26 januari 2011

PG Routing Shooting Star issue

screenshot43In a recent project I’m using PG Routing for routing with Navteq data. To route start to stop PGRouting comes with three different algorithms.

  • Djikstra – classic shortest path.
  • Shortest Path A* – using heuristics to find the shortest path.
  • Shortest Path Shooting Star – using heuristics with traffic rules to find the shortest path.

The Djikstra and Shortest Path A* works fine and are pretty fast after working with the network and bounding box. When trying the algorithm Shortest Path Shooting Star there are some problems. One major problem is when starting reverse direction of the first link.

Navteq’s segments starts from south. So when calculating a route on that starts off south there is a phenomena, see image. It should a straight line from the top point to the bottom point, very badly visualized.

onsdag 19 maj 2010

Tech Days 2010, blog posts and start with Bing Maps

Speaking Swedish or understand Swedish? If you are interested in BIng Maps, SharePoint, DeepEarth, Microsoft and GIS you can watch my presentation at Tech Days 2010 in Örebro, Sweden the 24th of Mars this year.

Lately Johannes Kebeck, a Bing Maps TSP blogged about my favorite project SMIL. That blog post is one post in a blog series about integrating maps into SharePoint. His latest post is about integration themetic maps from SQL Server 2008 R2.

If you are intested in starting developing with Bing Maps you should really go to Bing Maps portal. Johannes Kebeck, Chris Pendleton and BingMapsDev are people you can follow on twitter to get the latest news. Another good start is to go the developer forum. When should also have a look at Deep Earth Toolkit for Bing Maps.

onsdag 12 maj 2010

Creating a Silverlight Web Part for SharePoint 2007

In this blog post I describe an approach to add a Silverlight Web Part in SharePoint 2007. Adding Silverlight Web Parts to SharePoint can really make magic to SharePoint, i.e. maps (my personal favorite topic), Web Parts with drag and drop support from the file system etc. I always create a Silverlight project and separate and load it to a web part. I describe my favorite approach:

  1. Create a Web Part project, rename the Web Part and it’s files to something appropriate. I use Visual Studio 2008 extensions for Windows SharePoint Services 3.0 (version 1.2) in this example.
  2. Create a folder name it Templates.
  3. Create a folder name it ControlTemplates
  4. Create a folder name it YourWebPart-name.
  5. Choice File –> Add –> New Project. Choose web and give it a name.
  6. Get rid of the Default.aspx file in the web project.
  7. Add a User Control to the web project, get rid of the code behind and add your the reference to the web part assembly to the inherits of the file, example: <%@ Control Language="C#" AutoEventWireup="true"  Inherits="MyNameSpace.ClassName, AssemblyName, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=3283a693cab37f84" %> See understanding SharePoint for more info. The nice part now is that you can start designing the user control as with any .aspx-file, well almost. Add your .xap file and Silverlight.js-file to this project. 
  8. Add javascript and code for loading your silverlight control, i.e
    <div id="silverlightMultiFileUploadControlHost" >
    <object id="MultiFileUploader" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="450" height="280">
    <param name="source" value="/_controltemplates/mPost.MultiFileUpload/mpost.SilverlightMultiFileUpload.xap" />
    <param name="onerror" value="onSilverlightError" />
    <param name="initParams" value="MaxFileSizeKB=,MaxUploads=2,FileFilter=,ChunkSize=4194304,CustomParam=[site=<%=Site%>;docLib=<%=DocumentLibrary%>;httpService=<%=HttpService%>],DefaultColor=White" />
    <param name="background" value="white" />
    <param name="onload" value="pluginLoaded" />
    <param name="minRuntimeVersion" value="4.0.50401.0" />
    <param name="autoUpgrade" value="true" />
    <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.5040


    1.0" style="text-decoration:none">
    <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
    </a>
    </object>
    <iframe style='visibility: hidden; height: 0; width: 0; border: 0px'></iframe>
    </div>




  9. Add properties to your .cs file. I always add a SPWeb property to access the web from the user control and make sure that the .designer.cs file has the same class name.


  10. Go back to your web part project and add the following methods:

         protected override void OnLoad(EventArgs e)

            { SilverlightWebPart


                ScriptManager scriptManager = ScriptManager.GetCurrent(Page);


                if (scriptManager == null) 
                {  scriptManager = new ScriptManager();


                    Controls.Add(scriptManager); 
                } 
            }
     
            protected override void OnPreRender(EventArgs e)

            {


                base.OnPreRender(e);


                ClientScriptManager cs = Page.ClientScript; 
                if (!cs.IsClientScriptIncludeRegistered("sl_javascript"))


                    cs.RegisterClientScriptInclude(this.GetType(), "sl_ja vascript", "~/_controltemplates/mPost.MultiFileUpload/Silverlight.js");


                if (!cs.IsClientScriptIncludeRegistered("spsl_javascript"))


                    cs.RegisterClientScriptInclude(this.GetType(), "spsl_javascript", "~/_controltemplates/mPost.MultiFileUpload/SpSilverlight.js");


            }


  11. Of course you need to change the script source to your path.


  12. Add reference System.Web.Extensions


  13. Choóse add existing item in your web part project. Add your user control as a link (we want to compile it with the web part assembly), also add a Silverlight.js and your .xap file the same way to this folder.


  14. You’re done, all you have to do now is to load the user control to the web part in the CreateChildControls method like:
    mPost.MultiFileUploadWebPart.MultiFileUploadUC uc = (mPost.MultiFileUploadWebPart.MultiFileUploadUC)
    Page.Page.LoadControl("~/_controlTemplates/mPost.MultiFileUpload/MultiFileUploadUC.ascx");
    Controls.Add(uc);




In 14 steps I can write shiny cool Silverlight web parts for SharePoint 2007. There are some steps, especially with the 5 part assembly that is a little tricky. Of course my favorite Silverlight web part is the one in SMIL and Silverlight Multi File Upload that has inspired this blog post. See http://slfileupload.codeplex.com/SourceControl/changeset/view/47874#1002455 for a working code example.