Hot answers tagged

20

Assuming you use an ol.layer.Vector with an ol.source.GeoJSON you can use something like this: var vectorSource = new ol.source.GeoJSON({ projection : 'EPSG:3857', url: 'http://examples.org/fearures.json' }); var vectorLayer = new ol.layer.Vector({ source: vectorSource }); map.addLayer(vectorLayer); // show loading icon // ... var listenerKey = ...


18

In ol3 version 3.10.0 things have changed. So is more clear than older versions but still more complicated than ol2. So for TILE (ol.layer.Tile) layers your code snip should look like: //declare the layer var osmLayer = new ol.layer.Tile({ source: new ol.source.OSM() }); //asign the listeners on the source of tile layer osmLayer.getSource().on('...


16

I have written down a small piece of code might be helpful for you. You can try working example on jsFiddle <!DOCTYPE html> <html> <head> <title>Leaflet - Marker Click Event</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="http://...


13

Try to wrap your callback function in a separate function. Something like that: //here is you callback function function myCallback(evt){ var popup = new ol.Overlay.Popup({insertFirst: false}); map.addOverlay(popup); var prettyCoord = ol.coordinate.toStringHDMS(ol.proj.transform(evt.coordinate, 'EPSG:3857', 'EPSG:4326'), 2); ...


10

If you need a modifyend event why dont you use it within the modify interaction.(I guess you use a modify interaction) check this modify.on('modifyend',function(e){ console.log("feature id is",e.features.getArray()[0].getId()); }); This event is available in the latest versions of ol3. In my code snip, I assume you only modify one fetaure at once (getArray(...


9

ah ok dblclick is the answer // set mode to current mode of double clicked feature map.on('dblclick', function(evt) { console.log('doubled'); var feature = map.forEachFeatureAtPixel(evt.pixel, function(feature, layer) { // do stuff here }); }); and ...


8

Just a little CSS workaround will do the job for you. You can see the result in the following fiddle: http://jsfiddle.net/GFarkas/kkwgc1nh/ I made all of the images irresponsible to pointer events, so the clicks will fall through them and will activate the popup contents of the GeoJSON layer. The CSS code is: img.leaflet-tile{ pointer-events: none; } ...


8

Farid Cher's answer is partially correct. You can use the Progressor to 'catch' a cancel event from within a Python script, and you can also do whatever cleanup necessary as well, if you enclose the call within a try ... except clause. For example, a python toolbox: import arcpy import time class Toolbox(object): def __init__(self): self....


7

In OpenLayers 3 you have moveend, an ol.MapEvent triggered by the map itselft. Use it this way: map.on("moveend", function(e){ // event actions }); This event is triggered in many ways, after click or dblclick ol.MapBrowserEvent events. Hope it helps.


7

why dont you get the feature drawn and then get the coordinates out of it. It should be much faster. draw.on('drawend', function(e2) { var feature = e2.feature; var geometry = feature.getGeometry(); //depending on the type of geometry drawn you may get first and last //coordinate. From your description I guess you draw a linestring //you may clarify that ...


7

first you'll have to create your html elements ( buttons, radio, ... ) where you want to put + and -, here is an example using buttons : <button id="zoom-out">-</button> <button id="zoom-in">+</button> then you add a control on each one: var zoomType; document.getElementById('zoom-out').onclick = function() { zoomType="zoom-out"...


5

This sample would suggest that the API already separates a single click from drag events quite well (as well as double clicks). http://developers.arcgis.com/en/javascript/samples/map_infowindow/ Would you mind posting some code or at least explaining what you're doing with your custom onclick handler?


5

A more "leaflet" way to do it now is to set the interactive flag to be false. This will allow all events to be passed to other layers and ignored on this layer. L.geoJson(geoJsonData, { onEachFeature: aFunction, interactive: false }).addTo(group);


5

for the hover interaction you can use this code: hoverInteraction = new ol.interaction.Select({ condition: ol.events.condition.pointerMove, layers:[yourLayer] //Setting layers to be hovered }); map.addInteraction(hoverInteraction); the features in yourLayer will be highlighted when hovered, now for the select interaction you can either add a: ...


5

In case you would like to keep your registering function in its current form, the on method in OpenLayers returns the unique key assigned to the event listener function, which can be used with the ol.Observable.unByKey global function. function addFullScreenPopups(){ var evtKey = map.on('singleclick', function(evt) { var popup = new ol.Overlay.Popup({...


4

If you use arcmap 10.4 and up, you can set arcpy.env.autoCancelling = False to do the clean up work yourself. Example from official website. import arcpy arcpy.env.autoCancelling = False def my_function(tables, output): temp_tables = [] try: for table in tables: temp_tables.append(arcpy.CopyRows_management(table, '#')[0]) ...


4

I think creating event on layers(polygon layers) will work. layer_name.on('dblclick', function(e) { a = map.getZoom(); map.setZoom(a + 1);})


4

Either what @poshan has written, or add this line to onEachFeature(feature, layer): if( layer.options ) layer.options.clickable = false;


4

Another and perhaps better way through Leaflet code directly is to use the interactive flag. L.geoJson(gisData, { pane: 'apane', onEachFeature: someFunction, interactive: false }).addTo(something);


4

MapControl is an engine component to create your own window to display map contents. I've looked before and never found a way to get a reference to the ArcMap MapControl. ArcMap may not even use a MapControl for its display, it may use some other internal class. Two options: 1) var ave = ActiveView as IActiveViewEvents; ave.AfterDraw += onAfterDraw; ...


4

I'm not sure what you want to do exactly, but it looks like you want to receive an event when a layer is added to, or deleted from the map, right? Here's a sample: private IActiveViewEvents_Event _avEvents; private void SetupEventHandler() { var mxDoc = (IMxDocument)ArcMap.Application.Document; _avEvents = (IActiveViewEvents_Event)mxDoc.FocusMap; ...


4

JavaScript is error-tolerant only to some extent. It does not like your 2 function names separated by a comma. You know that in JS, whitespace / line breaks do not have a particular meaning besides separating identifiers and statements. You also know that in JS, an object is made of a list of property names and values. Therefore, the mouseover property ...


4

In OpenLayers 3 (or 4), features selection is handled by an interaction. The relevant doc about selection is here: http://openlayers.org/en/latest/apidoc/ol.interaction.Select.html Here's a piece of code that allows to select any features in your map, and to apply a special style to it (styleSelect): // render selected features with a red stroke var ...


4

Add the following to: <GeoJSON data={locations} onEachFeature={onEachFeature} />: onEachFeature(feature, layer) { const popupOptions = { minWidth: 250, maxWidth: 500, className: "popup-classname" }; const popupContentNode = <MyReactComponent />; const popupContentHtml = ReactDOMServer.renderToString(popupContentNode); ...


4

According to documentation, spatial reference argument should be a SpatialReference object. It also accepts some string type of spatial reference. But it may not accept wkt string of spatial reference like in your script. Therefore, try to create SpatialReference object. # other lines coordinate_system_string = """PROJCS['...


3

As an example, go to http://www.openlayers.org/dev/examples/click.html Type in your console map.events.listeners to get a list of registered events classified by events types. To see if you really added your event to the map, just count the type of events you registered. A sample could be console.log('Before adding a new click event', map.events....


3

This is already documented here. There are two undocumented tileerror events for the layer When a single tile is missing it trigger the event “loadwarning” to indicate that something is wrong with this layer. When all the tiles in a layer are missing it trigger the event “loadfail”. There is also some additional documentation in the code here UPDATE ======...


3

i'm not sure why .disableMouseEvents() stopped working after 3.9, but you can use map.setInfoWindowOnClick() instead. here's a working sample.


3

Get clicked XY coordinates in ol3 map.on('click', function(evt) { var coordinates = evt.coordinate; alert(coordinates); });


3

Currently, OpenLayers 3 doesn't provide a mechanism to know when sources/layers are loaded. This is planned, but not yet implemented. In the mean time, you can use your own imageLoadFunction. In your case: var source = new ol.source.ImageStatic({ url: '../cartes/img/' + newMapFileName, imageSize: [width, height], projection: pixelProjection, ...


Only top voted, non community-wiki answers of a minimum length are eligible