Skip to content

Wrong marker position on smaller zoom numbers #5

@virtualize

Description

@virtualize

Thank you very much for this fine library.

It seems like a marker it getting shifted up the smaller the zoom is, i.e. for zoom 12 the marker position seems good. If I decrease the zoom stepwise to smaller numbers, the marker will be positioned above (and more left) of the given coordinates.

In the following images the zoom is decreased from 12 to 8, 6 and 4.
At zoom 4 the marker is almost at germanys norther border, but the coordinates point to a place way south.

db7b1e5f-a6db-4942-9ee7-f1f59f245842
efddea52-d2e2-461e-849d-865ff37e0303
f68da997-483f-48b0-9767-d4921d17a078
4eac9f48-f4e7-4e88-920f-a14867c77152

My setup is rather simple

$tempFilePath = tempnam(sys_get_temp_dir(), 'osm');
$markerPath = $this->parameterBag->get('kernel.project_dir').'/assets/images/marker-black.png';

$markers = (new Markers($markerPath))
    ->setAnchor(Markers::ANCHOR_CENTER, Markers::ANCHOR_BOTTOM)
    ->addMarker(new LatLng($lat, $lng));

$map = (new OpenStreetMap(new LatLng($lat, $lng), $zoom, 640, 640))
    ->addMarkers($markers);

$map->getImage()->savePNG($tempFilePath);

I had a quick look at Markers::draw() but could not find the problem.

Edit: The marker anchor position does not seem to have anything to do with the misplacement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions