Saving pushpins to public map RRS feed

  • Question

  • Hello!

    I've recently embedded my bing map to my website, and went through the tutorial on how to add pushpins said map. I was wondering though - how do i save these pushpins people add to the map? I noticed when i refresh the page the pins disappear.


    Here's what i have so far: (using Microsoft's tutorial)

    function GetMap()
        var mapOptions = {
             credentials: "MYKEY",
             center: new Microsoft.Maps.Location(37.901164, -122.502264),
             mapTypeId: Microsoft.Maps.MapTypeId.road,
             zoom: 9,
             showScalebar: false
      // Initialize the map
      map = new Microsoft.Maps.Map(document.getElementById("myMap"), mapOptions),

      // Add a handler for the map click event.
      Microsoft.Maps.Events.addHandler(map, 'dblclick', addPin);


    function addPin(e) {
        if (e.targetType == "map") {
            var point = new Microsoft.Maps.Point(e.getX(), e.getY());
            var loc = e.target.tryPixelToLocation(point);
            var pin = new Microsoft.Maps.Pushpin(loc);


    Monday, November 24, 2014 4:23 AM


All replies

  • If you want people to be able to save the data on the map you will need to store it somewhere. If you want to keep the data on the client side you can look at storing the data as cookies or in a local database in the browser (Web database). If you want to keep the data online, and possibly make it available to multiple devices/people, you will need to create a web service and have a database to store the database. One of the easiest ways to do this is to use the Azure Mobile services. I wrote a blog post using Azure mobile service to create an auto complete function. IT shouldn't take much to turn it into what you want to do: http://blogs.bing.com/maps/2014/03/31/how-to-create-a-customer-ranked-auto-suggest-with-bing-maps-and-azure-mobile-services/

    If you need a really powerful Spatial web service you can create one as described in these blogs:




    Monday, November 24, 2014 10:27 AM
  • ~First let me please apologize for how novice i am - i am only just starting my learning of web design / development at school and i'm probably getting ahead of myself but i like little outside of school projects~

    Okay, so i'm using GoDaddy to host my website, where the map will be displayed, and i noticed i can add a database through my account. There is a database service address - and it's a MySQL database.

    1) does this mean i need to know / use SQL to speak with the database? I'm trying to learn some basic javascript stuff.

    2) can't i create a variable to store said points and transfer that data to the database?

    3) If i can store the points in said variable - wouldn't i be storing: var pin = new Microsoft.Maps.Pushpin(loc)?

    Thank you SO much!

    Monday, November 24, 2014 9:31 PM
  • If you are using GoDaddy and want to us MySQL then you will need to create a custom web service. You should be able to use Entity Framework with the database still. The last time I did this was several years ago and there were some issues back then that I had to work around which I documented here: http://rbrundritt.wordpress.com/2010/09/18/mysql-net-4-entity-framework-and-medium-trust-hosting-environments/

    When you have a custom web service you can create an object and pass it to the server side code and add it to the database. You would also have to have code to send that data to the client application.

    I recommend taking a look at Azure mobile services as it significantly simplifies this process and lets you pass JSON objects at the automatically created service and it modifies the database as needed to store the data. It also has authentication built in. (these aren't just for mobile apps, they work great for web pages too) http://azure.microsoft.com/en-us/documentation/services/mobile-services/

    It's also worth noting that you can create up to 10 websites on Azure for free. It's much faster and much more stable than GoDaddy. Also, deployment from visual studios is really easy. http://azure.microsoft.com/en-us/documentation/services/websites/


    Tuesday, November 25, 2014 4:55 PM