title: How to change the coordinates for an embedded OpenStreetMap in Laravel?
body: <p>We are trying to embed a map into our website. This works fine for a fixed address but we want the user to be able to change the address in the backend/dashboard if they want/need to. So the backend/dashboard has a form to fill in the address and it should update the map once submitted. But the map doesn't update and when we dd the return was null.</p>
  <p>We are using OpenStreetMap because we do not wish to pay for GoogleMaps API.</p>
  <p>Below is our code:</p>
  <pre><code>public function update(Request $request, Contact $contact)
      {
          $validated = $request-&gt;validate([
              'phone' =&gt; 'required',
              'mobile' =&gt; 'required',
          ]);
  
          $contact-&gt;building = $request-&gt;building;
          $contact-&gt;street = $request-&gt;street;
          $contact-&gt;city = $request-&gt;city;
          $contact-&gt;postcode = $request-&gt;postcode;
          $contact-&gt;phone = $request-&gt;phone;
          $contact-&gt;mobile = $request-&gt;mobile;
  
          $search_url = &quot;https://nominatim.openstreetmap.org/search?q=$contact-&gt;buiding+&quot;.str_replace(' ', '+', $contact-&gt;street).&quot;,+$contact-&gt;city&quot;;
          
          $httpOptions = [
              &quot;http&quot; =&gt; [
                  &quot;method&quot; =&gt; &quot;GET&quot;,
                  &quot;header&quot; =&gt; &quot;User-Agent: Nominatim-Test&quot;
              ]
          ];
          
          $streamContext = stream_context_create($httpOptions);
          $json = file_get_contents($search_url, false, $streamContext);
          
          $decoded = json_decode($json, true);
          $lat = $decoded[0][&quot;lat&quot;];
          $lng = $decoded[0][&quot;lon&quot;];
  
          $contact-&gt;longitude = $lng;
          $contact-&gt;latitude = $lat;
  
          $contact-&gt;save();
          return redirect()-&gt;route('contact.index')-&gt;with(&quot;message&quot;, &quot;Successfully updated.&quot;);
      }
  </code></pre>