Modular plug-in for customizable infobox control

As many of you know, the Bing Maps Locator Wizard is a portal that allows you to generate a Bing Maps Locator in minutes, and then have it hosted in Windows Azure for free. One of the steps in the wizard allows you to customize the style of various elements of the locator.
I was recently working on the wizard and required a highly customizable infobox control that would likely be put in an iframe. This article highlights some of the key features of the modular plug-in we created to allow for this requirement. The result far exceeded our expectations and InKnowledge has since released the code to the Bing Maps community so you can use it in your own applications. Feel free to download the complete source code, with sample implementations and documentation.


Modular Design The Bing Maps 7.0 Control was released last fall and is a complete rebuild from the ground up when compared to previous versions of Bing Maps. We have seen huge improvements in API performance and the size of the control. One feature of the map control was to use a modular framework; this allows you to register and load modules as they are needed. One result of this is faster loading speeds. Those interested in creating your own reusable modular plug-ins for Bing Maps should have a look at the documentation.
Custom Infoboxes When the 7.0 Control was originally released there were no infoboxes. The infobox control that Microsoft soon added was a bit different from past versions and was designed to be more flexible. While this is a great improvement, there are a couple of caveats to using this infobox control. The first is that the infobox always points up and to the right and does not reposition itself. This means that infoboxes that are anchored near the top are displayed outside of the map. This can be an issue if the map is being put in an iframe or the map is placed at the end of a webpage. The second caveat is that using custom HTML requires you to also generate the infobox arrow and content area, in addition to the content you want to display. Ideally we would be able to put custom HTML into the frame of the built-in infobox.
Positioning Our goal was to have the content positioned in the center of the map to ensure users can see the infobox. The solution: break the map into quadrants and modify the layout of the infobox such that the content is positioned in the middle of the map. For example, if the anchor point of an infobox is in the lower-left part of the map we want the infobox to be positioned to the right of the anchor point and pushed up. The easiest way to figure out what quadrant the anchor is located in is to convert the anchor coordinate to a pixel coordinate relative to the upper-left corner of the map. To determine if the anchor is to the left or right of the center of the map, simply check to see if the x-pixel coordinate is more or less than half the width of the map. Similar logic can be used to figure out if the anchor is above or below the middle of the map. Once we know if it is left or right of the center and above or below the center, we simply need to place the infobox so that it is in the opposite direction.
The Infobox Arrow One common issue that developers run into when trying to create customizable infoboxes is with the infobox arrow. In the past, these were almost always images that required edits if you wanted to change something as simple as the color. After a lot of research and experimenting, I found an ingenious solution: CSS borders. Years ago, when the web was young, webpages used to use really big borders to make things look like they were in a frame. As time went on the borders got smaller and smaller to the point where they are either not used or only 1 or 2 pixels wide. So where am I going with this? Well, if you look at a picture frame you might notice that the sides of the frame are connected in the corner at a 45-degree angle. This angle also occurs with CSS borders. If we take this and use a bit of fancy styling, we can modify the color and width of four edges of the border CSS class and generate an arrow. Not only can we generate an arrow, but with a little bit of logic and CSS styling, we can control the width, length. and color of the arrow. Check out this good article on creating angled shapes using the border style.
Additional Features The API for this custom infobox control is pretty basic. There are only four public methods that are exposed: hide, show, getOptions, and setOptions. The show method is pretty straightforward; it takes in a coordinate and content (either text or HTML). The content will be placed inside the infobox frame, rather than replacing it. By making the input generic we are able to use this infobox with pushpins, polylines, polygons, or on its own. As for options, not only can you set the dimensions and color of the arrow, you can also:
•    Set the background color of the content area of the infobox.
•    Set the color of the border on the infobox.
•    Specify minimum width and height for the content area.
•    Specify an offset distance from the anchor point.
•    Hide the arrow.
•    Hide the default close button.
•    Tether the infobox. The tether option allows one of two user experiences. When enabled the infobox will stay open and reposition itself as you move the map around until you close it. When disabled, the infobox will close when the map moves.
Implementing the Plug-in Implementing the custom infobox is easy. The first thing you must do is register the plug-in with the map control. You can do this using code similar to the following:
var map, customInfobox;
function GetMap() {
map = new Microsoft.Maps.Map(document.getElementById(“myMap”), { credentials: “Your_Bing_Maps_Key” });
//Register and load the Custom Infobox Module
Microsoft.Maps.registerModule(“CustomInfoboxModule”, “scripts/V7CustomInfobox.min.js”);
Microsoft.Maps.loadModule(“CustomInfoboxModule”, { callback: function () {
//Create an instance of the custom infobox control
customInfobox = new CustomInfobox(map);
}
});
}
To display an infobox, specify a coordinate and some content like the following:
customInfobox.show(map.getCenter(), “<b>Hello World</b>”);
We hope you find the plug-in helpful.

Google Offer Business Help Files

The help files for Google Offers have also been expanded to now include actual details about the program. I have abstracted some of the highlights:

Participation Requirements

  • To participate in Google Offers, you … should be financially stable, and must have positive customer reviews.

Concerns about meeting demand

Google will pay you 80% of your share 4 days after your offer purchase period ends.

Changing scheduled dates and canceling live offers

Once an offer is scheduled, there is very little flexibility to make changes to your start date

Once an offer is live, you won’t be able to cancel or make changes to the details, copy or terms

Offers selection and scheduling

How you’re notified if your offer is selected

In most cases, you’ll be notified at least 5 days before your offer is scheduled to run. In rare circumstances, we may choose to run your offer a few days earlier. The offer will have been approved by you beforehand, so the only difference would be that the offer is advertised 2 days earlier than scheduled. We’ll notify you if this is to happen.

We have an Editorial team that will help create the copy and any creative materials associated with your offer, with information that you provide. You will be able to review the offer and must give your final approval before it goes live for sale.


Creating and customizing Google Offers

Offer customization

You can customize many aspects of a Google Offer for your business. Here are just a few of the elements you can specify for your offer:

Number of offers a customer can purchase
Offer redemption period
Amount of discount on the offer
Store locations where the offer may be redeemed

Payments and refunds for Google Offers

Receiving payments for your offer sales

We will help you set up a special account with us, where you will enter your bank account information. Google will automatically initiate proper payouts per terms you’ve agreed to. Once a payment has been initiated, your bank may take up to three additional business days to register the payout in your bank account.

Payout schedules

Generally speaking, you’ll receive a payout for 80% of your sales approximately 4 days after your offer runs, minus any refund requests that have been processed. Google will hold the remaining 20% for a specified number of days to cover any refunds that may be processed during that period.

Refunds for Google Offers

Customers may request a refund from Google for an unused offer within 60 days of purchase for any reason. After 60 days, Google issues refunds in accordance with applicable local law and/or at our discretion. Refunds may be deducted from your account per agreed upon terms.

Offer redemption options

A customer will need to print a paper voucher or show a mobile version of the purchased offer that includes the barcode or redemption code to the business. The redemption code is directly below the barcode on the voucher.

Redemption options

There are three main types of redemption you can utilize in order for your customers to cash in on their purchase.

  1. Redemption via the Google Offers Business Dashboard
    You are able to enter in the redemption codes within your Offers account. To get the codes, you may accept a printed version of the offer or allow your customer to bring up the code on their mobile device. If you don’t enter the codes in individually at the time of purchase, we recommend entering all codes by the end of the day.
  2. Google Offers Toll Free Phone System (not yet available)
    Using a special toll-free number, your customers will be able to enter their redemption code through the phone.
  3. Google Offers Mobile Business Ap
    The merchant redemption app for Android is a simple application that allows you to scan barcodes from a printed offer or from another mobile device’s screen.
    • Sign in to the mobile app with your Google Offers account
    • Select ‘Barcode Scanner’ to scan a barcode or choose ‘Manual Entry’ to manually type in the redemption code
    • The app will confirm whether or not the Offer code is valid
    • Click the button to redeem the Offer*
      *If you ever scan the barcode again or type in the same code, the Offer will no longer be valid

Google Offers Program Policies

The policies note a range of items that can not be promoted via Offers and includes range of products and services such as tobacco, firearms and hacking