Updates - Adds fuzzy coordinates to realtys in the API and the PHP-SDK (release v1.1.25)

31 January 2020

API

request:

/rest/v1/objekt/detail?id=1234567&culture=de

/rest/v1/projekt/detail?id=1234567&culture=de

There are new elements ungenaue_verortung_... inside the <geo> element.

<geo>
    ...
    <user_defined_simplefield feldname="ungenaue_verortung_laengengrad">15.01234</user_defined_simplefield>
    <user_defined_simplefield feldname="ungenaue_verortung_breitengrad">48.56789</user_defined_simplefield>
    <user_defined_simplefield feldname="ungenaue_verortung_radius">500</user_defined_simplefield>
    ...
</geo>

PHP-SDK v1.1.22

The SDK supports fuzzy coordinates. Warning: They can be empty, depending on the realty’s visibility setting.

<?php
$realty->getLongitudeFuzzy(); // returns float|null
$realty->getLatitudeFuzzy(); // returns float|null
$realty->getRadiusFuzzy(); // returns int|null

Example: Displaying the realty’s location circle via Google Maps.

Display a circle on Google Maps via Javascript. Zooms to the circle automatically.

This code expects the coordinate and the radius to be passed to the map canvas as data attributes.

jQuery(document).ready(function() {

    // zoom to the circle
    function calcZoomLevel(radius, lat, edgeLength) {
        // show a little bit more than the circle
        var metersPerPixelNeeded = radius * 3 / edgeLength;
        var zoomNeeded           = Math.log2(156543.03392 * Math.cos(lat * Math.PI / 180) / metersPerPixelNeeded);

        return Math.floor(zoomNeeded);
    }

    var $canvas    = $('#my_map_id');
    var latLng     = new google.maps.LatLng($canvas.data('lat'), $canvas.data('lng'));
    var radius     = $canvas.data('radius');

    if (!radius) {
        // in case we do not have fuzzy coordinates, display a marker...
    } else {
        var edgeLength = Math.min($canvas.height(), $canvas.width());
        var mapOptions = {
            zoom:      calcZoomLevel(radius, latLng.lat(), edgeLength),
            center:    latLng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        var map        = new google.maps.Map($canvas[0], mapOptions);
        new google.maps.Circle({
            center:        latLng,
            radius:        radius,
            map:           map,
            draggable:     false,
            editable:      false,
            fillColor:     '#0000ee',
            fillOpacity:   0.15,
            strokeColor:   '#0000ee',
            strokeOpacity: 0.5,
            strokeWeight:  1
        });
    }
});