Bing map start location loaded dynamically from parent page field

kyle shapiro asked on February 20, 2015 01:03

I have multiple pages corresponding to various American States. Each of these pages use the same layout, and they each contain a Bing map. I would like for them all to have different starting locations and zoom levels corresponding to that American State. The Bing web-part only accepts number types for the "longitude/latitude" fields that determine the map starting position. I do not want to use an ad-Hoc version of the template for each and every one of these pages, because I would like to be able to change the design at any time. The idea that I have come up with, (and please suggest different ways if you have any ideas) is to:

  1. Create a "State" page-type with fields "Longitude/Latitude/zoom-Level"
  2. Make a copy of the Bing map web-part and alter it to accept references the value of these State-page's custom fields as the values for the Longitude/Latitude/zoom-level fields.

This way all the pages can use the same template and the Content managers can create a new State Page and simply fill in the value of the longitude/latitude/zoom-level and the map will be instantiated for them. If this is a good approach to the problem, I failed somewhere in step #2. I doubt I did the C# correctly, as I am not very skilled with it. Can anybody help me, or suggest a better approach?

Correct Answer

Brenden Kehren answered on February 20, 2015 13:47

I haven't worked with the Bing maps webpart before, I tend to use the Google maps one more. For testing purposes check out the Google maps webpart and there are lat and long fields on there. You simply enter the column names for your page type and it will automatically place the lat and long values in place when you select the state.

For instance, your content tree looks like this:

- States
-- Minnesota
-- Wisconsin

The page, States, has your page template with the webpart assigned to it. You can set the visibility of the webpart to only show for your custom page type, this way when you navigate to a state it will automatically inherit that States template and it will only show for the individual State.

In your custom page type (or check out the "Office" page type), add a field for the zoom level (as you suggested). In your webpart set the large scale view to a default like 10. For the detail scale view, set the value to a macro like

{% YourZoomLevelColumnName %}

This will allow you to dynamically draw that value out of that field when someone navigates to the details of that State.

1 votesVote for this answer Unmark Correct answer

Recent Answers

kyle shapiro answered on February 20, 2015 18:22

Thank you for your response Brenden. I was able to get it to work with the following macros. {% CurrentDocument.Latitude #%} {% CurrentDocument.Longitude #%} {% CurrentDocument.DefaultMapZoomLevel #%}

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.