An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
Very odd. Looks like you can only draw two points (start/end of a single line). I suspect something is blocking the click event in the drawing manager from firing which would add the point to the shape and allow for the next point in the shape to be previewed/drawn.
A couple things to check and try:
- Try commenting out your mouseover/mouseout/click events to see if that resolves the issue. If it does, then uncomment them one by one. This should help narrow down what we need to look into.
- Check that your event handlers don't call the
preventDefaultfunction that's on the event argument as that will prevent the event from bubbling through to other functions in the map, like drawing tools. - Double check that your event handlers aren't throwing any errors. It's possible an error there could be prevent the rest of the event handlers in the stack from being fired.
- It sounds like you have a bunch of events added to each layer that do similar things for each layer and have some custom code that aggregates these somehow. A simpler/cleaner option might be to simply add your events to the map and not the layer, then check the event arguments to see if there was a shape in the arguments, and if so, which data source the shape came from. I've added a code sample below: <!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<style><link href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.css" rel="stylesheet" /> <script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.js"></script> <script> var map, datasource1, datasource2, testDataSize = 10; function GetMap() { //Initialize a map instance. map = new atlas.Map('myMap', { view: 'Auto', authOptions: { authType: 'subscriptionKey', subscriptionKey: '<Your Azure Maps Key>' } }); //Wait until the map resources are ready. map.events.add('ready', function () { //Create two data sources, add some random points, and a connect a layer to each data source. datasource1 = new atlas.source.DataSource('Blue pin source'); map.sources.add(datasource1); datasource1.add(generateRandomPoints(testDataSize)); map.layers.add(new atlas.layer.BubbleLayer(datasource1)); datasource2 = new atlas.source.DataSource('Red pin source'); map.sources.add(datasource2); datasource2.add(generateRandomPoints(testDataSize)); map.layers.add(new atlas.layer.BubbleLayer(datasource2, null, { color: 'red' })); //Add a click event to the map. map.events.add('click', function (e) { var topItem = 'map'; if(e.shapes && e.shapes.length > 0){ var topShape = e.shapes[0]; if(topShape instanceof atlas.Shape){ topItem = `Shape from data source "${topShape.dataSource.id}"`; } else { //Shape is a GeoJSON feature. Ensure the source isn't 'vectorTiles' which is the basemaps data source. if(topShape.source !== 'vectorTiles') { topItem = `Shape from data source "${topShape.source}"`; } } } document.getElementById('output').innerText = `${topItem} has been clicked.`; }); }); } function generateRandomPoints(cnt) { var layerData = []; for (var i = 0; i < cnt; i++) { layerData.push(new atlas.data.Feature(new atlas.data.Point([Math.random() * 360 - 180, Math.random() * 170 - 85]), { title: 'Pin_' + i })); } return layerData; } </script>
body, html, #myMap {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
}
</style>#output { position: absolute; top: 10px; left: 10px; padding: 10px; background-color: white; }
</head>
<body onload="GetMap()">
<div id="myMap"></div>
</body><div id="output"></div>
</html>