i need your help. I`m using bing maps tile source.
const tileSource = new Microsoft.Maps.TileSource({
uriConstructor: 'someapi',
enableCors: true,
minZoom,
maxZoom
});
I'm using REST api and it needs header for security. i can`t understand how can i set a header in uri constructor if it only needs string. I know that i can use callback, but it is also return only string. Any help?
Tile layers in Bing Maps do not expose a way to set the header on tile requests.
Related
I'm adding a number of icons created from imageSprite.createFromTemplate() method however sometimes I'm receiving the following error . How to resolve it using "styleimagemissing" event? How to find out which image is missing to add in the callback ?. And the symbol layer created using the icons sometimes overlaps over the bubble layer(cluster layer) too in some clusters. I don't know if that is caused due to missing images. Thanks in advance.
atlas.min.js:55 Image "Scaffold Builder_Inactive_Icon" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.
The styleimagemissing event will tell you the ID of the image that is missing. It won't tell you which symbol layer is trying to use that image however as a single image may be used by multiple layers.
Here is an example of how to use this event:
var iconLoaded = {};
//Add an event to handle the situation when an image is missing from the sprite.
map.events.add('styleimagemissing', function (id) {
//Check to see if the image is has been or is being loaded. Don't try and load the image multiple times.
if (!iconLoaded[id]) {
iconLoaded[id] = true;
//Load the custom image icon into the map resources.
map.imageSprite.add(id, '../Common/images/icons/showers.png').then();
}
});
A complete sample is available here: https://github.com/Azure-Samples/AzureMapsCodeSamples/blob/master/AzureMapsCodeSamples/Symbol%20Layer/Load%20missing%20image%20into%20sprite.html
I am trying to call an api with location to display a GeoJson object on the bing map. I wrote the code below but nothing gets displayed on the map and no errors also.
Could you please see anything wrong with this code?
var api = 'https://api/locations';
Microsoft.Maps.loadModule('Microsoft.Maps.GeoJson', function () {
Microsoft.Maps.GeoJson.readFromUrl(api,
function (shapes) {
//Add the shape(s) to the map.
map.entities.push(shapes);
}, 'callback');
});
Thank you
Does the service you are calling wrap the response with JavaScript? Your code has 'callback' which is telling Bing Maps to make a JSONP request which will append &callback=[some internal callback function] to the request. If your service doesn't use JSONP and is hosted on the same domain or is on a CORs enabled endpoint, remove the callback parameter from your code.
I have a module that uses google maps to make a map, get the users location and place a marker on the map where they are. I wanted a custom animated marker so I had to make a factory initializing a custom OverlayView Class. I also wanted the map loaded asynchronously so I created a factory like this
to handle loading google maps.
I can load the map fine by doing this:
initializer.gMapReady.then(function(){
//call service method to make map
});
But I dont know how to use my initializer for my OverlayView factory that looks like this:
.factory('locMarker', function() {
LocationMarker.prototype = new google.maps.OverlayView(); // This returns the error, google is not defined
function LocationMarker(opts) {
this.setValues(opts);
}
LocationMarker.prototype.draw = function() {
//
// Code for drawing the marker on the map
//
}
};
return LocationMarker;
})
Whenever I load the page the map shows up fine but my custom marker never displays. I get a reference error, google is not defined, that points to the line LocationMarker.prototype = new google.maps.OverlayView(); If I don't lazy load google maps and just add the script to the index page everything runs fine.
Is there a way for me to call my maps initializer from within the locMarker factory so that google maps is loaded before it tries to construct the class?
Update:
As estus mentioned in the comments, I could use a resolver in the states/routes but I am trying to make this module not require that if possible.
I am using the WebBrowser control on a Windows Forms application in Visual Studio 2010 - targeting .Net framework 3.5.
I have loaded the contents of the WebBrowser control via setting the DocumentStream property. The stream content is from the response to an Http (POST) request to a third party web page which is called in code using the HttpWebRequest object. We need to use the POST request verb type. The form is populated with data based on the request parameters.
Within the Windows application, the user needs to fill out a few additional text fields and then submit. Having been loaded via the stream, the page has no knowledge of full url of the original page. Therefore the submit fails (displays the name of the page in the WebBrowser control).
Is there any way to give the control the full path to the document such that the Submit operation will have the correct context? Setting WebBrowser.Url property does not work as this simply results in navigation to the page without the data displayed as it is not passed any parameters.
Below is the code (so far):
//Class to call website to make http post
var webBridge = new WebCallHandler();
//Make the request. Response returned as string
var result = webBridge.MakeHttpRequest();
//Get string as stream
var byteArray = Encoding.ASCII.GetBytes(result);
var stream = new MemoryStream(byteArray) { Position = 0 };
//webBrowser1.Url = new Uri(URL);
webBrowser1.DocumentStream = stream;
//Need to set the context of the page like "http://example.com/somepage.aspx"
var dom = webBrowser1.Document.DomDocument;
If you have filled the result variable (which seems to be a string), you should rather easily be able to modify the contents.
Using e.g. Regular Expressions or HTML Agility Pack to search for the
<form ... action="relative-url" ...
and replace it with
<form ... action="http://somedomain.com/relative-url" ...
then pass it to the DocumentStream property of your browser.
I searched the string being returned from the HttpWebrequest for the form element action attribute. This only showed the name of the page received from the httpWebRequest. I modified it in code to be the full url.
Thanks for your comment Kevin. This was the prompt that helped.
Does anyone have some sample code for toggling a KML overlay layer with a checkbox? I can get a kml layer on my map to toggle off when I uncheck the checkbox, but I can't get it to toggle back on. I've viewed all sorts of sample sites and code, but can't get this thing to work. The site in question is at www.fhitestsite.com/mdctest.
Thanks.
1) Your problem is that map var is not defined -
you defined var map inside a one function but trying to call it from other one. Define it outside of the function
...
var map;
var todayLayer;
var todayShown = 1;
var todayWdgt;
...
2) minor error. todayWdgt is NULL. Its just that you try to assign something that doesn't exist yet.
You should run this code after the document is ready.
todayWdgt = document.getElementById("todayBtn");
todayWdgt.checked = true;
Try using firebug.