Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Point fixed to view (eg. cross of center view)

Tags:

openlayers-3

What is the optimal way to position the fixed point of view (not to the point on the map). Using for showing middle of the view, while watching GPS positioning and moving center of the map according to current coordinates.

like image 955
eXMarty Avatar asked Oct 24 '25 21:10

eXMarty


1 Answers

You can do this with pure html and css. Inside your map div, place another div:

<div id="map" class="map">
  <div id="center"></div>
</div>

Then add some css to position it in the center of the map viewport:

#center {
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-top: -20px;
    margin-left: -20px;
    padding-top: 10px;
    padding-left: 10px;
    border: 2px solid red;
    z-index: 10000;
    position: relative;
}

I created a JSFiddle so you can play with it: http://jsfiddle.net/wce6zqor/.

like image 123
ahocevar Avatar answered Oct 28 '25 05:10

ahocevar