none
Set image on to bing map RRS feed

  • Question

  • I try set image and detail box to bing map.i write the html code in my cs file  and pass it to the html file when function fire.

    but it dosen't appear on the map.  in 6.3 it work properly,but not with 8.0.Is there any changes to do?

    I need to get some details when i click on that image also,

     

    chabha

    Monday, October 10, 2016 9:15 AM

Answers

  • Ok, I think I know what you are talking about. In V6.3 polylines and polygons used to have a pushpin attached to them. Majority of developers just hide this and it was generally considered a pain. V7 removed the pushpin that was attached to these shapes (v6.3 was replaced by v7 over 5 years ago). V8 is very similar to v7 and also doesn't add a random pushpin to shapes.

    If you want to add a pushpin to a shape you can do this. You can calculate the center of a shape using the centroid function in the Spatial Math library: https://msdn.microsoft.com/en-US/library/mt762861.aspx This will provide you with a coordinate. Use this and create a pushpin like normal. Here is a code sample for using the centroid function: http://www.bing.com/api/maps/sdk/mapcontrol/isdk#getCentroid+JS


    [Blog] [twitter] [LinkedIn]

    Wednesday, October 12, 2016 6:59 PM
  • You should be passing in your Polyline, not a pushpin. Also, you don't have a pushpin at this point, you are trying to create one, but first need to calculate the centroid of the line. Here are a couple of examples:

    Places a pushpin on the centroid of the polyline:

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
        credentials: 'Your Bing Maps Key',
    	zoom: 2
    });
    
    Microsoft.Maps.loadModule('Microsoft.Maps.SpatialMath', function () {
        var line = new Microsoft.Maps.Polyline([
    		new Microsoft.Maps.Location(45, -110),
    		new Microsoft.Maps.Location(30, -105)])
        map.entities.push(line);
    	
        var pin = new Microsoft.Maps.Pushpin(Microsoft.Maps.SpatialMath.Geometry.centroid(line));
        map.entities.push(pin);
    });
    


    [Blog] [twitter] [LinkedIn]

    Thursday, October 13, 2016 6:45 PM

All replies

  • Can you provide more details on what you are trying to do. It is not clear what you are trying to accomplish. Do have a code sample?

    [Blog] [twitter] [LinkedIn]

    Monday, October 10, 2016 9:13 PM
  • Ok, I think I know what you are talking about. In V6.3 polylines and polygons used to have a pushpin attached to them. Majority of developers just hide this and it was generally considered a pain. V7 removed the pushpin that was attached to these shapes (v6.3 was replaced by v7 over 5 years ago). V8 is very similar to v7 and also doesn't add a random pushpin to shapes.

    If you want to add a pushpin to a shape you can do this. You can calculate the center of a shape using the centroid function in the Spatial Math library: https://msdn.microsoft.com/en-US/library/mt762861.aspx This will provide you with a coordinate. Use this and create a pushpin like normal. Here is a code sample for using the centroid function: http://www.bing.com/api/maps/sdk/mapcontrol/isdk#getCentroid+JS


    [Blog] [twitter] [LinkedIn]

    Wednesday, October 12, 2016 6:59 PM
  • when i try 

    Microsoft.Maps.SpatialMath.Geometry.centroid(pushpin);

    It gives script error "Geomatry undefined or null refrence"

    Why is that?Is that a error with loading or error with url that i used to get the map? 


    chabha

    Thursday, October 13, 2016 9:10 AM
  • You should be passing in your Polyline, not a pushpin. Also, you don't have a pushpin at this point, you are trying to create one, but first need to calculate the centroid of the line. Here are a couple of examples:

    Places a pushpin on the centroid of the polyline:

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
        credentials: 'Your Bing Maps Key',
    	zoom: 2
    });
    
    Microsoft.Maps.loadModule('Microsoft.Maps.SpatialMath', function () {
        var line = new Microsoft.Maps.Polyline([
    		new Microsoft.Maps.Location(45, -110),
    		new Microsoft.Maps.Location(30, -105)])
        map.entities.push(line);
    	
        var pin = new Microsoft.Maps.Pushpin(Microsoft.Maps.SpatialMath.Geometry.centroid(line));
        map.entities.push(pin);
    });
    


    [Blog] [twitter] [LinkedIn]

    Thursday, October 13, 2016 6:45 PM
  • That's Work Great.

    Thank you Very Much for your help.


    chabha

    Friday, October 14, 2016 4:13 AM