Is there an option/method available to restrict mapboxgl directions setting origin/destination on map click - mapbox-gl-js

Need to toggle mapboxgl directions and based on its value the origin/destination should be set.

Related

leaflet.js - Questions about polyline

I have some questions about leaflet's polyline and they are as follows
Is there a way when instantiating the polyline (L.polyline) to dictate that it should not show by default on the map? I know that I can use .addTo([map]) and .remove() but is there a way to specify as part of the options?
What is the best practice to hide/show polylines that are used to indicate a path between markers (L.marker)? I know that I can add the markers to a layer group (L.layerGroup). I know that when creating the polyline, I can use the same lat/lng for each of the markers indicating the path. I know that I can show/hide each one of those individually (using L.Control.Layers and passing in the layer groups in as overlay maps and using that control to show/hide the markers and then, again, using the addTo() and .remove() for the polylines) but what I'm hoping to get help with is to make it show that the polylines show/hide when the layer group is visible/not visible and also show/hide them using an external control. For the former case, I've tried using feature groups (L.featureGroup) but I could not get it to work. For that latter case am I limited to .addTo() and .remove()?
thnx,
Christoph

Stop click propagation on a custom div within a leaflet map

I have a custom div (with settings) within a map. I would like click event not to propagate to map when a user clicks on the div. How could one achieve such behavior?
Leaflet version 1.0.
See the documentation for L.DomEvent.stopPropagation().
For anyone else coming here from a search engine, if you are trying to prevent clicks from a circle or other interactive layer from being handled by the underlying object (other circle or the map itself) you could also create the layer passing the option bubblingMouseEvents: false
Documentation: http://leafletjs.com/reference-1.2.0.html#interactive-layer

How to turn off the draggable behavior in Bing Maps API 7.0

I am building a map application using the Bing Maps API 7.0 javascript control. I am trying to figure out how to toggle the default "draggable" behavior of the map. I want my users to be able select a rectangular region by clicking in one corner, and then dragging the mouse to the other corner. Is this possible?
I'm not asking for any help with the selection behavior, just the ability to toggle the draggable behavior. Thanks!
The easiest way to do this is to set the map options to disable panning/zooming:
map.setOptions({disableZooming: true, disablePanning: true});
When you want to be able to move the map again then set these values to false.

Bing Maps Ajax v7 Directions Module incorrectly sets bounds when map layer is hidden

I have a relatively simple web app, that allows the user to enter two waypoints (from and to locations), then click a button to get the directions itinerary and a map with the route path plotted on the map.
The app was laid out so that the form, the itinerary and the map where in separate "tabs" and the layers could be shown and hidden based on the tab selection.
Oddly, the map would always be zoomed right out to the minimum zoom (entire world view) although the pushpins (waypoints) and route path were correctly plotted, the map bounds were not being honored. If the map was visible, then those route path bounds were honored and the map functioned as expected.
An example of this is here: http://jsfiddle.net/junto/DMR2T/
Click on 'Get Directions' when the map is visible, and the map is zoomed to the correct bounds. Then toggle the map and click 'Get Directions' again. Toggle the map back to visible. You'll see the map has the incorrect zoom level and bounds.
Lastest build of Google Chrome, Safari, Firefox all display this issue. Internet Explorer does not.
Is this a bug?
My guess is that in order to properly compute zooming and bounds, the map needs to know its display size. In order for the map to know that, it needs to be visible. So a workaround would be to move the map off screen rather than hiding it.
See my updated example here: http://jsfiddle.net/ZWzjC/
In my example I simply set a negative left margin, I'm sure there are more clever ways to move something off the screen while maintaining its visibility. I tried using visibility:hidden but that doesn't seem to hide the map correctly. display:none won't work since that causes the map to have 0 dimensions, and that's what .toggle() probably uses internally anyway.

How to disable Bird's eye angled view in Bing Maps control version 7

For business use Microsoft charge extra for use of the Bing Maps birds eye angled view, so my client has ask that I disable this option. In verion 6.3 of the control this was easy, there is a map option that can be used to do this: enter link description here
However, I can't find how to do this using the API with version 7 of the control. The current menu has Birds eye as an option with check boxes show labels and show angled view. Ideally I'd like to disable the option from the menu so that users are only able to view road and aerial views. So it looks like I have two options available:-
1) Hide the show angled view check box somehow with css. The issue here is that I can't get to the HTML content using the IE developer toolbar of firebug as it only displays when selected.
2) Attach to the map maptypechanged event and if birds eye map selected set it back to the map type it used to be.
Both of the above are far from ideal. Does anyone have a suggestion for the best way of doing this?
Sample code:
map = new Microsoft.Maps.Map(document.getElementById('myMap'),
{
credentials: 'Your Bing Maps Key',
disableBirdseye:true
});
here are some working examples from the iSDK:
http://www.bingmapsportal.com/isdk/ajaxv7#CreateMapWithMapOptions14
API Reference:
And here is the MSDN:
http://msdn.microsoft.com/en-us/library/gg427603.aspx
disableBirdseye
boolean
A boolean indicating whether to disable the bird’s eye map type. The default value is false. If this property is set to true, bird’s eye will be removed from the map navigation control and the birdseyeMapTypeId is disabled. Additionally, the auto map type will only display road or aerial.
This property can only be set when using the Map constructor.
You're correct in stating that there is no way currently using the v7 API to disable individual map styles. A possible Option #3 which is less hackish, but requires a bit more work, is to set the showMapTypeSelector property of the MapOptions to false, which would have the effect of hiding the entire map style selection dropdown. Then create your own custom navigation menu that only includes links to those styles you want to allow the user to choose.