Skip to content

Commit

Permalink
Inversion LAT et LNG dans le retour de l'API et création d'une page d…
Browse files Browse the repository at this point in the history
…e test map #37
  • Loading branch information
oceanBigOne authored and ColinMaudry committed Mar 31, 2017
1 parent 8b05b33 commit 0c692b7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion class/Candidature.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ public function geocode(){
$geometry=$features[0]["geometry"];
if(array_key_exists("coordinates",$geometry)){
if(count($geometry["coordinates"])==2){
$coordinate=array("lat"=>$geometry["coordinates"][0],"lng"=>$geometry["coordinates"][1]);
$coordinate=array("lat"=>$geometry["coordinates"][1],"lng"=>$geometry["coordinates"][0]);
}

}
Expand Down
14 changes: 14 additions & 0 deletions pages/visitor/candidature/map.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

$oListeCandidature=new CandidatureListe();
$oListeCandidature->applyRules4ListVisitor();
$aCandidatures=$oListeCandidature->getPage();
$aObj=array();
foreach($aCandidatures as $aCandidature){
$oCandidature=new Candidature(array("id"=>$aCandidature["id"]));
$oCandidature->hydrateFromBDD(array('*'));
array_push($aObj, $oCandidature);
}


$aDataScript["candidatures"]=$aObj;
25 changes: 25 additions & 0 deletions templates/visitor/candidature/map.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<html><body>
<div id="mapdiv"></div>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script>
map = new OpenLayers.Map("mapdiv");
map.addLayer(new OpenLayers.Layer.OSM());
var center = new OpenLayers.LonLat( {{ candidatures[0].lng }} ,{{ candidatures[0].lat }} )
.transform(
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
map.getProjectionObject() // to Spherical Mercator Projection
);
var zoom=8;
var markers = new OpenLayers.Layer.Markers( "Markers" );
map.addLayer(markers);
{% for candidature in candidatures %}
markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat( {{ candidature.lng }} ,{{ candidature.lat }} )));
{% endfor %}
map.setCenter (center, zoom);
</script>
</body></html>

0 comments on commit 0c692b7

Please sign in to comment.