npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

osm-locationpicker

v0.1.0

Published

Open Street Maps location picker with Google Maps API search.

Downloads

4

Readme

JQuery Location Picker plugin

This plugin allows to find and select location on OpenStreetMap map using Google geoode API for address autocomplete and reverse geocoding.

Supports address autocomplete search and location select on map click.

Address autocomplete is using Google Maps Api, Maps displayed via OpenLayers

Plugin saves location information in inputs and provides same data via callbacks.

jquery-location-picker-demo

#jquery #location-picker, #maps, #autocomplete, #geocode, #OpenStreetMap, #OSM, #OpenLayers

Features

  • Location Search by address
  • Address autocomplete
  • Location pick on map click
  • Reverse address geocode from location
  • Initialize location picker with:
    • current location
    • custom address
    • custom location(latitude,longitude)
  • Save location data in inputs or use in js callbacks
  • Specify custom map and inputs elements

Code Example & Minimal setup

See Sample.html demo for configuration and usage

Include required scripts:

<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'></script>
<script src='http://www.openlayers.org/api/OpenLayers.js'></script>
<script src='https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places'></script>

then add location picker plugin reference:

<script src='js/location-picker.js'></script>

Example markup:

<style>
  	#map { height: 400px; width:100%;}
  	.map-container { margin-top: 10px;}
</style>

    
<div class='location-picker'>
	<input type='text' id='txtAddress' class='form-control' placeholder='Enter your address here' data-type='address' />
	<input type='hidden' id='txtLocation' data-type='location-store' />

	<div class='map-container'>
		<div id='map' data-type='map'></div>
	</div>
</div>

Usage:

<script>
$(function(){
		var locationPicker = $('.location-picker').locationPicker({
			locationChanged : function(data){
				$('#output').text(JSON.stringify(data));
			}
		});
});
</script>

Location picker API Reference

locationPicker looks for elements with data-type='address', data-type='location-store' and data-type='map' in specified selector by default.

Those elements could be changed via initialization options.

Location selected callback function, initial location information could be passed as well.

All available options are:

<script>
var locationPicker = $('.location-picker').locationPicker({
			{
				address_el : 'input[data-type="address"]', // address autocomplete input
				map_el: '[data-type="map"]', // map element to render OSM map in
				save_el: '[data-type="location-store"]', // Location information is stored in this input in JSON format
				raw_data: false, /* if true, full place information is returned in JSON format 
				False by default, returns latitude, longitude and address string in JSON format
				*/			
				init:{ 
					current_location: true, // True by default, initializes location picker with current location 
					address : 'Put init adddress here',
					location : {latitude, longitude} // put initial location here
					}
			}
			// callback method
			locationChanged : function(data){

				$('#output').text(JSON.stringify(data));
			}
			
		});
</script>

Location Picker methods:

  • getData() - returns current location data
  • getAddress() - returns address string
  • setAddress(address) - sets location picker address and shows location on map
  • setLocation(lat, long) - sets location and reverse geocodes it's address

Contributors

License

The MIT License (MIT)