Перетаскиваемая и нажимаемая канцелярская кнопка на карте Bing в JavaScript - PullRequest
0 голосов
/ 14 февраля 2012

Кто-нибудь есть способ поместить перетаскиваемые кнопки через Bing API, используя JavaScript? Даже возможно иметь эту функциональность через API (javascript)?

Ответы [ 2 ]

2 голосов
/ 14 февраля 2012

Ответ есть!http://www.bingmapsportal.com/ISDK/AjaxV7#Pushpins13

var pushpinOptions = {icon: 'poi_custom.png', draggable:true}; 
var pushpin= new Microsoft.Maps.Pushpin(map.getCenter(), pushpinOptions); 
pushpindragend= Microsoft.Maps.Events.addHandler(pushpin, 'dragend', enddragDetails);  
map.entities.push(pushpin);
0 голосов
/ 22 января 2018

Еще одно решение с перетаскиваемой канцелярской кнопкой и перетаскиваемым информационным блоком

<!DOCTYPE html>
<html>
<head>
    <title>pushpinDragEventsHTML</title>
    <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
    <style type='text/css'>body{margin:0;padding:0;overflow:hidden;font-family:'Segoe UI',Helvetica,Arial,Sans-Serif}</style>
</head>
<body>
    <div id='printoutPanel'></div>

    <div id='myMap' style='width: 100vw; height: 100vh;'></div>
    <script type='text/javascript'>


        function loadMapScenario() {
        var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {});
        var center   = map.getCenter();
        var Events   = Microsoft.Maps.Events;
        var Location = Microsoft.Maps.Location;
        var Pushpin  = Microsoft.Maps.Pushpin;
        var pins = [
                new Pushpin(new Location(center.latitude, center.longitude), { color: '#00F', draggable: true }),
            ];

             // Setting up the pin_coordinates printout panel
            document.getElementById('printoutPanel').innerHTML = '<div id="pushpinDragEnd">' + center +'</div>';      

            var infobox = new Microsoft.Maps.Infobox(
                center, { 
                title: 'Map Center',
                description: 'Initail Lable' });
                infobox.setMap(map);


            map.entities.push(pins);

            // Binding the events for the pin
            Events.addHandler(pins[0], 'dragend', function () {  displayPinCoordinates('pushpinDragEnd'); });


            function displayPinCoordinates(id) {
                    infobox.setMap(null); // delete infobox
                    var pin_location =pins[0].getLocation();

                    document.getElementById(id).innerHTML =pin_location;   // display pin coordinates in printout panel

                    // display dragged infobox
                    infobox = new Microsoft.Maps.Infobox(
                        pin_location, { 
                        title: 'Pin Center',
                        description: 'Dragable Lable' });
                        infobox.setMap(map);
            }

        }


    </script>


    <script type='text/javascript' src='https://www.bing.com/api/maps/mapcontrol?key=yourBingMapsKey&callback=loadMapScenario' async defer></script>
</body>
</html>
...