November Happy Hour will be moved to Thursday December 5th.

Google Maps and dynamic locations

Vote:
 

Hello!

I have a bunch of Office Cards that i'd like to display on a map interface (Google maps). These Office Cards has 2 properties each, Longitude and Latitude, and I've worked out the following before I completly blacked out. My code consists of a DummyPage where I run everything, a Google Map-webcontrol (with all the scripts set up properly) and so on. I also have a containerpage apart from my epitree-structure where I store the Contact Cards, and two help classes called PageHelper and Maphelper. What i'd like to do is to look at all the children of my container page for the Office Cards and grab the two properties Longitude and Latitude. Here's where im struggling, in Maphelper:

 

 public class MapHelper
{

public static Dictionary<string, List<MapPoint>> GetMapPoint()
{
Dictionary<string, List<MapPoint>> poiLists = new Dictionary<string, List<MapPoint>>();



PageData startpage = Utilities.PageHelper.GetPageWithAccessCheck(PageReference.StartPage);
PageDataCollection pdc = new PageDataCollection(poiLists);
if (startpage.IsValue("OfficePageContainer"))
{
PageReference pr = startpage["OfficePageContainer"] as PageReference;
if (pr != null)
{
pdc = DataFactory.Instance.GetChildren(pr);
}

}


foreach (PageData pd in pdc)
{
if (pd.IsValue("Longitude") && pd.IsValue("Latitude"))
{

//How do I select these and shove em into my map??
}
}

 

Any help or valuable links is greatly apprechiated. Thanks!

 

 

#56892
Feb 14, 2012 20:02
Vote:
 

Also not using PageTypeBuilder :( 

#56893
Feb 14, 2012 20:03
Vote:
 

Inside your last if statement, if you get this far you know that this PageData object has the requied properties. Not sure how your MapPoint class looks, but I guess it has two properties for Longitude and Latitude that you then can set and add to your collection.

Hard to tell without knowing what you plan to use poiLists for and what MapPoint looks like.

Frederik

 

#56896
Feb 14, 2012 22:41
Vote:
 

Hi Robin,

 

So if understand correctly you have managed to get the coordinates of the offices and you want to show them on your map?

 

One option could be to return the list of coordinates and insert them to your page type as inputs in the html:

<input type="hidden" value="longitude,latitude">

And on page load you collect the info from these inputs and outputs them with the google map javascript API.

Look at this example: (http://code.google.com/intl/sv-SE/apis/maps/documentation/javascript/examples/icon-simple.html)


function initialize() {
var myOptions = {
zoom: 4,
center: new google.maps.LatLng(-33, 151),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);

var image = 'images/beachflag.png';
var myLatLng = new google.maps.LatLng(-33.890542, 151.274856);
//use document.getElementsByTagName and loop trough all inputs and create a new marker.

var beachMarker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: image
});
}

 

 More info on the Google map api can be found here: http://code.google.com/intl/sv-SE/apis/maps/documentation/javascript/tutorial.html

 

Edit:

Made a quick gist to show what i meant:

https://gist.github.com/1835468

#56911
Edited, Feb 15, 2012 13:22
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.