Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

491
Visualizações
unable to get property 'getRegularPolygon' of undefined or null

I use invokescript in C# to call on SetCoords and it seems like everything's working fine until it runs into the "getRegularPolygon" line. I can't find any documentation for the method but I got the second half of the SetCoords function from this: https://docs.microsoft.com/en-us/bingmaps/v8-web-control/map-control-concepts/spatial-math-module-examples/geolocation-accuracy-circle-example Other places I've looked for answers say something about "getelementbyid" but that doesn't seem to apply here.

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge" />
    <script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?callback=GetMap&key={mykey}' async defer></script>
    <script type='text/javascript' async defer>
        var map, infobox, pushpin, radius;
        var centerlattitude = 0.0;
        var centerlongitude = 0.0;
        
        function GetMap() {
            var center = new Microsoft.Maps.Location(centerlattitude, centerlongitude);
            map = new Microsoft.Maps.Map('#myMap', { center: center, zoom: 20 });
            pushpin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(centerlattitude, centerlongitude + 0.0005), { draggable: true });
            map.entities.push(pushpin);
            Microsoft.Maps.Events.addHandler(pushpin, 'changed', getNewCenter);
        }
        function SetCoords(lat, long, rad) {
            centerlattitude = lat;
            centerlongitude = long;
            radius = rad;
            GetMap();
            var path = Microsoft.Maps.SpatialMath.getRegularPolygon(center, radius*1000, 8, Microsoft.Maps.SpatialMath.Meters);
            var poly = new Microsoft.Maps.Polygon(path);
            map.entities.push(poly);
        }
</body>
</html>
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You need to load the spatial math library. Bing Maps is modularized to help reduce the overall size of applications so that developers only load in the parts they need to ensure fast initial loading of the app. Note that loading of modules is asynchronous, so you have to run your code that accesses the module, after it has finished loading. Here is an example:

//Load the spatial math module
Microsoft.Maps.loadModule("Microsoft.Maps.SpatialMath", function () {
    var path = Microsoft.Maps.SpatialMath.getRegularPolygon(center, radius*1000, 8, Microsoft.Maps.SpatialMath.Meters);
    var poly = new Microsoft.Maps.Polygon(path);
    map.entities.push(poly);
});
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda