Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exemple de surcharge de la fonction d'export au format GPX de l'outil…
… de dessin (Drawing)
- Loading branch information
1 parent
0172589
commit 38679f2
Showing
4 changed files
with
183 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta content="IE=edge,chrome=1; charset=UTF-8" http-equiv="X-UA-Compatible"> | ||
<title>sample ol3 MousePosition</title> | ||
|
||
<!-- Library OpenLayers 3 --> | ||
<link rel="stylesheet" href="../../../lib/ol3/ol.css" /> | ||
<!-- <script src="../../../lib/ol3/ol-debug.js"></script> --> | ||
|
||
<!-- Plugin OpenLayers 3 IGN --> | ||
<link rel="stylesheet" href="../../../dist/ol3/GpPluginOl3.css" /> | ||
<!-- <script src="../../../dist/ol3/GpPluginOl3.js" data-url="./../resources/AutoConf.js"></script> --> | ||
|
||
<!-- requirejs --> | ||
<script src="../../../lib/require.js"></script> | ||
|
||
<!-- load geoportail-waiting image --> | ||
<style> | ||
div#map { | ||
background-image:url(../resources/geoportail-waiting.gif); | ||
background-position:center center; | ||
background-repeat:no-repeat; | ||
max-width: 800px; | ||
height: 300px; | ||
margin: 10px; | ||
} | ||
</style> | ||
|
||
</head> | ||
<body> | ||
<h1> | ||
<a href="http://openlayers.org/"><img src="../resources/logo-ol3.png" alt="OpenLayers3" width="100" /></a> | ||
<a href="http://www.ign.fr"><img src="../resources/logo-ign.jpg" alt="IGN" width="100" /></a> | ||
</h1> | ||
<h3> | ||
OpenLayers3 - A high-performance, feature-packed library for all your mapping needs. | ||
</h3> | ||
|
||
<div> | ||
<p>Ajout d'un widget d'affichage des coordonnées de la souris (x, y et H)</p> | ||
|
||
<script> | ||
var map; | ||
/* global requirejs */ | ||
requirejs.config({ | ||
"baseUrl" : "../../../src/", | ||
"paths": { | ||
// lib external | ||
"ol" : "../lib/ol3/ol-debug", | ||
"proj4" : "../lib/proj4/proj4", | ||
"gp" : "../lib/gp/GpServices-src", | ||
"sortable" : "../lib/sortable/Sortable", | ||
"woodman" : "../lib/woodman/woodman-amd" | ||
} | ||
}); | ||
requirejs( | ||
["ol", "gp", | ||
"Ol3/Layers/LayerWMTS", | ||
"Ol3/Controls/Drawing"], | ||
function (ol, Gp, | ||
LayerWMTS, | ||
Drawing) { | ||
|
||
var createMap = function () { | ||
|
||
// Création de la map | ||
map = new ol.Map({ | ||
target : "map", | ||
layers : [new LayerWMTS({ | ||
layer: "GEOGRAPHICALGRIDSYSTEMS.MAPS", | ||
})], | ||
view : new ol.View({ | ||
center : [288074.8449901076, 6247982.515792289], | ||
zoom : 8 | ||
}) | ||
}); | ||
|
||
// creation du controle | ||
var drawing = new Drawing(); | ||
|
||
// surcharge de la fonction d'export : kml to geojson | ||
Drawing.prototype.onExportFeatureClick = function () { | ||
console.log("overload!"); | ||
var oKml = new ol.format.KML({ | ||
writeStyles : true | ||
}) ; | ||
var kml = oKml.writeFeatures(this.layer.getSource().getFeatures(), { | ||
dataProjection : "EPSG:4326", | ||
featureProjection : this.getMap().getView().getProjection() | ||
}) ; | ||
console.log("KML", kml); | ||
|
||
var oGpx = new ol.format.GPX(); | ||
var gpx = oGpx.writeFeatures(this.layer.getSource().getFeatures(), { | ||
dataProjection : "EPSG:4326", | ||
featureProjection : this.getMap().getView().getProjection() | ||
}) | ||
console.log("GPX", gpx); | ||
|
||
}; | ||
map.addControl(drawing); | ||
|
||
}; | ||
|
||
Gp.Services.getConfig({ | ||
serverUrl : "./../resources/AutoConf.js", | ||
callbackSuffix : "", | ||
// apiKey: "jhyvi0fgmnuxvfv0zjzorvdn", | ||
timeOut : 20000, | ||
onSuccess : createMap | ||
}); | ||
}); | ||
</script> | ||
|
||
<!-- map --> | ||
<div id="map"> | ||
</div> | ||
|
||
<!-- Comment utiliser le plugin avec un exemple --> | ||
<p>EXEMPLE D'UTILISATION</p> | ||
<pre> | ||
<code> | ||
window.onload = function () { | ||
var map = new ol.Map({ | ||
layers: [ | ||
new LayerWMTS({ | ||
layer: "GEOGRAPHICALGRIDSYSTEMS.MAPS", | ||
}) | ||
], | ||
target: 'map', | ||
view: new ol.View({ | ||
center: [288074.8449901076, 6247982.515792289], | ||
zoom: 5 | ||
}) | ||
}); | ||
map.addControl(new MousePosition({})); | ||
} | ||
</code> | ||
</pre> | ||
|
||
<!-- Toutes les informations utiles sur ol3 --> | ||
<p> | ||
<ul> | ||
<li>En savoir plus avec le <a href="http://openlayers.org/en/v3.11.2/doc/quickstart.html">quick start guide</a>,</li> | ||
<li>d'autres informations avec <a href="http://openlayers.org/en/v3.11.2/examples/">les exemples</a>,</li> | ||
<li>ou aller directement à l'<a href="http://openlayers.org/en/v3.11.2/apidoc/">API documentation</a>.</li> | ||
</ul> | ||
Si vous avez des questions, jetez un oeil à la | ||
<a href="http://stackoverflow.com/questions/tagged/openlayers-3">FAQ</a>. | ||
</p> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters