For #1, add the ignore placement and allow overlap options to the text options as well. It appears that if there is an image for a symbol, it won't display unless the text is displayed as well.
For #2, if you want to filter points within a polygon on the map, there are two approaches. The first is to filter the points ahead of time via code and only include the filtered data inside the data source. This is good if you need to both filter the points on the map and need to know what is shown to do something outside of the map. The other is to use the within
data driven expression which allows you pass in a polygon into the filter of a layer and it will automatically limit which points are displayed. This does the visual filter but doesn't tell you which points are displayed. Here is an example data driven expression:
['within', {"type": "Polygon""coordinates": [[[-114.33170,45.54248],[-118.17243,38.71702],[-102.38278,39.84012],[-114.33170,45.54248]]]} ]
If you want to create a user experience where the user draws areas on the map and filters the points, the Azure Maps Selection Control module provides this capability, and also exposes a reusable function for doing point in polygon calculations.
Azure Maps includes a set of standard geospatial math functions but doesn't dive too deep into "boolean operations" as the code for those can grow very quickly, and there are different methods that can produce different results depending on if the user wants geospatial or pixel accuracy. Turf.js is a well-established geospatial math library that's been around for years and is used by thousands of big companies. It's worth noting a large percentage of geospatial math capabilities in most geospatial platforms come from open-source libraries such as Java Topology Suite which has been around for well over 20 years and has a .NET version NetTopoloygySuite. All that said, if you simply want point in polygon and nothing more complex than that, there is a fair easy way to do this with decent performance (higher performance can be achieved using graphs, but then the code gets a lot bigger, and that's what these libraries take care of). Here is a simple point in polygon function for GeoJSON data:
function pointInRing(point, ring) {
var x = point.coordinates[0], y = point.coordinates[1];
var inside = false;
for (var i = 0, j = ring.length - 1; i < ring.length; j = i++) {
var xi = ring[i][0], yi = ring[i][1];
var xj = ring[j][0], yj = ring[j][1];
var intersect = ((yi > y) !== (yj > y)) && (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
if (intersect) inside = !inside;
}
return inside;
}
function filterPointsWithinPolygon(points, polygon) {
//A polygon can have one or more rings. The first ring is the external outline, while additional rings are holes in the polygon.
return points.filter(function(point) {
//Make sure the point is within the external ring.
if(pointInRing(point, polygon.coordinates[0])){
//Make sure the point is not inside any of the holes.
for(var i=1;i<polygon.coordinates.length;i++){
//If the point is in any hole, fail.
if(pointInRing(point, polygon.coordinates[0])) {
return false;
}
}
}
return true;
});
}